I've got a jenkins server from which I download build artefacts. The job is set up in a way that the build artefact includes the job number like NightlyBuild-346.tar.bz2. The job number helps make it easy to know when the job was build. The problem is that I dont know the name of the file I'm downloading. I know I want the last successful build. I did something like this.
- name: download build from CI
get_url:
url: "https://ci.contoso.com/job/NightlyBuild/lastSuccessfulBuild/artifact/NightlyBuild-345.tar.bz2"
dest: /tmp/NightlyBuild-345.tar.bz2
But this breaks jenkins after the build finishes because the artefact becomes NightlyBuild-346.tar.bz2. The options that I have here are:
- Try to use wildcards in the get_url module (not so sure about that)
- Download ALL artifacts from the job (there are several) as a single archive.zip and use command-line and regex magic to find the actual build artifact I care about. (potential for a hot unmaintanable mess)
- Use the REST API to obtain the job number for the last successful job and form the full URL. (not sure that Ansible allows me to set variables on-the-fly like that).
Is there any better way to do this or are these my only options? In the end I'd like to publish to an artifactory repo from jenkins.