Jenkins multiple artifacts for the same build

JenkinsJenkins Plugins

Jenkins Problem Overview


Is there a way to save/archive multiple artifacts from the same build?

Jenkins only allows a single 'Archive the Artifacts' post build step, and grey's out the option after it has been used once.

Maybe the ArtifactsArchiver's allows multiple patterns?

Jenkins Solutions


Solution 1 - Jenkins

You can use Ant-style pattern, e.g. target/*.jar to archive multiple artifacts.

And it is possible to use a comma separated list of patterns if your files can't be matched with one pattern, e.g. target/*.jar, target/*.war.

The ? button next to the input field reveals this info.

Solution 2 - Jenkins

You can comma separate the paths, like this:

XXX.UnitTests\bin\Release\**.* , XXX.WriteAPI.Service/bin/Release/**.*

Then you get two separate artifacts.

See http://ant.apache.org/manual/Types/fileset.html for details of the Ant Pattern syntax.

Solution 3 - Jenkins

If you want to save two different types of files like zip files and html files, then you can use

*.html,*.zip

It will help you to archive all zip files and html files in that directory.

Solution 4 - Jenkins

No, jenkins does not provide only one artifact to save. You can use wild card pattern to same any number of artifacts, For example All Jars - **/.jar All War - **/.war and so on.

**/ means Any directory.

Solution 5 - Jenkins

All the answers on here show how to combine multiple file patterns into 1 artifact which is not what the OP asked for.

An example of what was asked for is to have something like a Single Page Web app build that has environment specific settings compiled into the JavaScript for QA, Staging and Production.

As you would want to deploy the same build to multiple environments, you would need 3 builds, each with it's own environment settings in it. When you deploy the archive, you would not want to deploy the contents of all 3 to each environment and extract just the content for that one environment, because it is expensive to copy 66% more than is needed each time and could be error prone.

So, it is reasonable to generate 2 or more builds into their own artifacts and deploy 1 of those artifacts, depending on the target environment.

Jenkins should support multiple artifacts, not just making 1 artifact bigger.

Solution 6 - Jenkins

Copying @Steven the Easily Amused's comment on one of the bottom-ranked answers for visibility. You can just run it twice:

> Notice that the step names are plural. One can run archiveArtifacts - > the pipeline step - as often as desired though it's more efficient to > run it once with Ant style patterns. When invoked archiveArtifacts > transports the selected file(s) back to the master where they are > stored. Similarly one can run copyArtifacts multiple times to select > all of or a portion of the archived Artifacts.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionthunderbirdView Question on Stackoverflow
Solution 1 - JenkinsdaspilkerView Answer on Stackoverflow
Solution 2 - JenkinsDavid LilljegrenView Answer on Stackoverflow
Solution 3 - JenkinsJagadeesh PulamarasettiView Answer on Stackoverflow
Solution 4 - Jenkinsvishal sahasrabuddheView Answer on Stackoverflow
Solution 5 - JenkinsAntony BoothView Answer on Stackoverflow
Solution 6 - JenkinsNoumenonView Answer on Stackoverflow