Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documentation on archiveArtifacts command in Jenkins

I'm working on a basic Jenkins pipeline. The build and testing are successful but I'm looking at how to archive the build. For context, this is a simple Rust webserver.

Under the pipeline steps documentation in the Basic Steps plugin, it has the archive function. But it says:

Archives build output artifacts for later use. As of Jenkins 2.x, you may use the more configurable archiveArtifacts.

I cannot find any documentation on archiveArtifacts. There are some examples, but I would like to look at the documentation for it, what parameters it accepts, i.e. what makes it more configurable than archive.

My question: is there a place where this documentation is best found? jenkins.io is incomplete and wiki.jenkins.io is missing this command.

like image 745
pmbotter Avatar asked Dec 18 '17 22:12

pmbotter


People also ask

What is Jenkins archiveArtifacts?

archiveArtifacts : Archive the artifacts. Archives the build artifacts (for example, distribution zip files or jar files) so that they can be downloaded later. Archived files will be accessible from the Jenkins webpage.

How do you save artifacts in Jenkins pipeline?

Normally, Jenkins keeps artifacts for a build as long as a build log itself is kept, but if you don't need old artifacts and would rather save disk space, you can do so. Note that the Maven job type automatically archives any produced Maven artifacts. Any artifacts configured here will be archived on top of that.

How do I archive multiple artifacts in Jenkins pipeline?

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/*.


1 Answers

I suggest archiveArtifacts: Archive the artifacts from the Pipeline Steps Reference.

Archives the build artifacts (for example, distribution zip files or jar files) so that they can be downloaded later. Archived files will be accessible from the Jenkins webpage. Normally, Jenkins keeps artifacts for a build as long as a build log itself is kept, but if you don't need old artifacts and would rather save disk space, you can do so.

Note that the Maven job type automatically archives any produced Maven artifacts. Any artifacts configured here will be archived on top of that. Automatic artifact archiving can be disabled under the advanced Maven options.

  • artifacts
    You can use wildcards like 'module/dist/**/*.zip'. See the includes attribute of Ant fileset for the exact format. The base directory is the workspace. You can only archive files that are located in your workspace.
    • Type: String
  • allowEmptyArchive (optional)
    Normally, a build fails if archiving returns zero artifacts. This option allows the archiving process to return nothing without failing the build. Instead, the build will simply throw a warning.

    • Type: boolean
  • excludes (optional)
    Optionally specify the 'excludes' pattern, such as "foo/bar/**/*". A file that matches this mask will not be archived even if it matches the mask specified in 'files to archive' section.

    • Type: String
like image 83
sschmeck Avatar answered Sep 28 '22 13:09

sschmeck