Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading artifacts from Jenkins using wget or curl

I am trying to download an artifact from a Jenkins project using a DOS batch script. The reason that this is more than trivial is that my artifact is a ZIP file which includes the Jenkins build number in its name, hence I don't know the exact file name.

My current plan of attack is to use wget pointing at: /lastSuccessfulBuild/artifact/ to do some sort of recursive/mirror download.

If I do the following:

wget -r -np -l 1 -A zip --auth-no-challenge --http-user=**** --http-password=****  http://*.*.*.*:8080/job/MyProject/lastSuccessfulBuild/artifact/

(*s are chars I've changed for posting to SO)

I never get a ZIP file. If I omit the -A zip option, I do get the index.html, so I think the authorisation is working, unless it's some sort of session caching issue?

With -A zip I get as part of the response:

Removing ...+8080/job/MyProject/lastSuccessfulBuild/artifact/index.html since it should be rejected.

So I'm not sure if maybe it's removing that file and so not following its links? But doing -A zip,html doesn't work either.

I've tried several wget options, and also curl, but I am getting nowhere.

I don't know if I have the wrong wget options or whether there is something special about Jenkins authentication.

like image 607
Erik Avatar asked Jul 15 '15 13:07

Erik


People also ask

How do you save artifacts in Jenkins?

Go to your client project and select configure. Create a post-build action and select 'archive artififacts' from the drop down menu. Add the type of files you want to archive (and eventually, copy and export).

Where Jenkins artifacts are stored?

By default, Jenkins archives artifacts generated by the build. These artifacts are stored in the JENKINS_HOME directory with all other elements such as job configuration files.

How do I use Jenkins artifacts?

In Jenkins, an artifact is created in either Freestyle projects or Pipeline projects. In Freestyle, add the “Archive the artifacts” post-build step. In Pipeline, use the archiveArtifacts step.

How do you publish artifacts in Jenkins pipeline?

Publish a package using JenkinsSelect your build pipeline, and then select Configure to edit your build definition. Select Build, and then select Add build step to add a new task. Select Save, and then queue your build. Your NuGet package should be published to your Azure Artifacts feed.


1 Answers

You can add /*zip*/desired_archive_name.zip to any folder of the artifacts location.

If your ZIP file is the only artifact that the job archives, you can use:

http://*.*.*.*:8080/job/MyProject/lastSuccessfulBuild/artifact/*zip*/myfile.zip

where myfile.zip is just a name you assign to the downloadable archive, could be anything.

If you have multiple artifacts archived, you can either still get the ZIP file of all of them, and deal with individual ones on extraction. Or place the artifact that you want into a separate folder, and apply the /*zip*/ to that folder.

like image 83
Slav Avatar answered Sep 19 '22 14:09

Slav