So I created some tasks in one of my roles today that queries Jenkins to 
find the latest build of a project and then uses that build number to go 
get a zip file onto one of my managed servers.

The relevant part of my tasks/main.yml looks like this:

- uri: 
url=http://jenkins/job/BuildSomeProject/api/json?tree=lastSuccessfulBuild[number]
 
method=GET return_content=yes
  delegate_to: localhost
  register: jenkins_response
  tags: latest

- debug: var=jenkins_response.json.lastSuccessfulBuild.number

- name: get specified zip
  win_get_url:
    url: 
'http://jenkins/job/BuildSomeProject/lastSuccessfulBuild/artifact/zip/someProject.{{jenkins_response.json.lastSuccessfulBuild.number}}.zip'
    dest: 
'C:\stagingArea\zips\someProject.{{jenkins_response.json.lastSuccessfulBuild.number}}.zip'

It works fine (thank you whoever created uri: module) but I'd like to 
assign a single variable name, say {{latestBuildNumber}}, rather than the 
{{jenkins_response.json.lastSuccessfulBuild.number}} which is a bit of a 
mouthful.

Maybe I'm thinking in programming mode and this is just the way it has to 
be, but I have the feeling I've been at the screen too long and I'm missing 
something obvious.

Jenkins can return a bunch of useful information about builds actually, so 
it would be nice to grab > 1 thing and assign it a more meaningful name 
that doesn't directly reference the structure of the json response.

Many thanks,

Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b61d49d3-f188-4153-8bbe-306742e5e11a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to