7
votes

I'm using Jenkins and have the "Archive the Artifacts" step at the end of my builds to archive them into a zip file.

Instead of using this step, I'd like to use a script to push the artifacts to a remote server at the end of the build. The server I'm pushing to uses a REST API / HTTP PUT request in a script to upload files.

Note that I'm looking to access the artifact created in the same build. So if I'm on build #5, I want the artifacts from build #5, not build #4.

Is there any way to access this zip file with a script, in the same build that it was created in?

I need to upload this zip remotely and don't want to create another job to do so.

3

3 Answers

5
votes

You can install one of the "Publish Over..." plugins to upload your artifacts at the end of a build.

The goal of the Publish Over plugins is to provide a consistent set of features and behaviours when sending build artifacts ... somewhere.

See also the full list of "upload" plugins for other methods of publishing your artifacts.

4
votes

Like @Christopher said, you can use any of the Publish Over plugins on the Jenkins Plugins page to upload the artifact to any of the

If you want to access the archived zip file from within the build itself, you can use the following link to access it:

http://<server>/job/${JOB_NAME}/lastSuccessfulBuild/artifact/<artifact name w/folder>

For example:

  • server = myserver.com
  • job name = myproject
  • artifact = del/project.zip

Your URL would be:

http://myserver.com/job/myproject/lastSuccessfulBuild/artifact/del/project.zip

EDIT: Question was changed. In any case, this would work for accessing the artifact of the previous build in the current one.

1
votes

There is no way that I have found to access the "Archive the Artifacts" package of the build that generates it. This step always occurs last in the build. Accessing the URL prior to the build ending (during the build via script for example) results in a blank zip file. To get around this limitation, I'm making a second linked build job to grab the zip and run my script to deploy it.