How to download file from jenkins artifact using wget where file name version will be changing

Viewed 619

Using below code i am able to download srww_1.2.3.4.dmg file but file version number will change daily so i cannot hardcode filename.

How to download file without hardcoding file name.

wget "https://test.com/job/testreport/job/${{parameters.test_buildjob}}/lastSuccessfulBuild/artifact/directrs/srww_1.2.3.4.dmg" --no-check-certificate --http-user=$(USERNAME) --http-password=$(PASSWORD) --auth-no-challenge --no-verbose -O srww_1.2.3.4.dmg

Please help me.

1 Answers

I suggest you take a look at the ReST API of Jenkins:

https://test.com/job/testreport/job/${{parameters.test_buildjob}}/lastSuccessfulBuild/api

Particularly, the XML or JSON form should provide you with the version number built by the job, so you can get the version number first, and then use it when calling to wget.

Related