[continuous-integration] Archive the artifacts in Jenkins

Could someone please explain to me the idea of artifacts in the build process?

I have the workspace directory where I check out the code to compile and run my ant scripts etc. At the end, in my case, I get a jar file that's ready to install. Is that considered to be the artifact?

Where should I tell my build script to put the jar file? In the workspace directory? My jar file gets a unique filename depending on variables like BUILD_ID and such, how can I tell Jenkins which jar file to pick?

EDIT: Okay, so i tried doing something like this:

enter image description here

The path does not exist yet in my workspace, because the build script is supposed to create it, and of course, the .jar and .properties files are not there because they haven't been generated yet. Why does it give me an error then? Seems like I'm missing something.

Also, does Jenkins delete the artifacts after each build (not the archived artifacts, I know I can tell it to delete those)? Otherwise it will clog the hard drive pretty quickly.

This question is related to continuous-integration hudson archive jenkins artifacts

The answer is


In Jenkins 2.60.3 there is a way to delete build artifacts (not the archived artifacts) in order to save hard drive space on the build machine. In the General section, check "Discard old builds" with strategy "Log Rotation" and then go into its Advanced options. Two more options will appear related to keeping build artifacts for the job based on number of days or builds.

The settings that work for me are to enter 1 for "Max # of builds to keep with artifacts" and then to have a post-build action to archive the artifacts. This way, all artifacts from all builds will be archived, all information from builds will be saved, but only the last build will keep its own artifacts.

Discard old builds options


Also, does Jenkins delete the artifacts after each build ? (not the archived artifacts, I know I can tell it to delete those)

No, Hudson/Jenkins does not, by itself, clear the workspace after a build. You might have actions in your build process that erase, overwrite, or move build artifacts from where you left them. There is an option in the job configuration, in Advanced Project Options (which must be expanded), called "Clean workspace before build" that will wipe the workspace at the beginning of a new build.


An artifact can be any result of your build process. The important thing is that it doesn't matter on which client it was built it will be tranfered from the workspace back to the master (server) and stored there with a link to the build. The advantage is that it is versionized this way, you only have to setup backup on your master and that all artifacts are accesible via the web interface even if all build clients are offline.

It is possible to define a regular expression as the artifact name. In my case I zipped all the files I wanted to store in one file with a constant name during the build.


Examples related to continuous-integration

Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject Jenkins vs Travis-CI. Which one would you use for a Open Source project? Continuous Integration vs. Continuous Delivery vs. Continuous Deployment How do I clone a job in Jenkins? How to trigger Jenkins builds remotely and to pass parameters How to connect Bitbucket to Jenkins properly Managing SSH keys within Jenkins for Git How to uninstall Jenkins? How to set environment variables in Jenkins? Jenkins CI: How to trigger builds on SVN commit

Examples related to hudson

How/When does Execute Shell mark a build as failure in Jenkins? How to create and add users to a group in Jenkins for authentication? In Jenkins, how to checkout a project into a specific directory (using GIT) Jenkins - passing variables between jobs? How are environment variables used in Jenkins with Windows Batch Command? Jenkins/Hudson - accessing the current build number? Error - trustAnchors parameter must be non-empty Archive the artifacts in Jenkins Jenkins / Hudson environment variables How to trigger a build only if changes happen on particular set of files

Examples related to archive

iOS how to set app icon and launch images Create a tar.xz in one command How to do a "Save As" in vba code, saving my current Excel workbook with datestamp? Tar archiving that takes input from a list of files Archive the artifacts in Jenkins How to create a zip archive of a directory in Python? How to create a zip archive with PowerShell? Shell command to tar directory excluding certain files/folders How do I tar a directory of files and folders without including the directory itself? Zip folder in C#

Examples related to jenkins

Maven dependencies are failing with a 501 error Jenkins pipeline how to change to another folder Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock groovy.lang.MissingPropertyException: No such property: jenkins for class: groovy.lang.Binding How to solve npm install throwing fsevents warning on non-MAC OS? Run bash command on jenkins pipeline Try-catch block in Jenkins pipeline script How to print a Groovy variable in Jenkins? Jenkins pipeline if else not working Error "The input device is not a TTY"

Examples related to artifacts

How to manually deploy artifacts in Nexus Repository Manager OSS 3 How do I force Maven to use my local repository rather than going out to remote repos to retrieve artifacts? Archive the artifacts in Jenkins