# Is there a way to make my var less ugly?

**URL:** <https://forum.ansible.com/t/is-there-a-way-to-make-my-var-less-ugly/16426>\
**Category:** Ansible Project\
**Created:** [October 3, 2014, 11:03pm UTC](https://forum.ansible.com/t/is-there-a-way-to-make-my-var-less-ugly/16426 "2014-10-03T23:03:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [October 3, 2014, 11:03pm UTC](https://forum.ansible.com/t/is-there-a-way-to-make-my-var-less-ugly/16426/1 "2014-10-03T23:03:05Z")

</div>

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]](http://jenkins/job/BuildSomeProject/api/json?tree=lastSuccessfulBuild%5Bnumber%5D) 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}](http://jenkins/job/BuildSomeProject/lastSuccessfulBuild/artifact/zip/someProject.%7B%7Bjenkins_response.json.lastSuccessfulBuild.number%7D)}.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

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [October 4, 2014, 12:35am UTC](https://forum.ansible.com/t/is-there-a-way-to-make-my-var-less-ugly/16426/2 "2014-10-04T00:35:13Z")

</div>

You can use the set\_fact module for that.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [October 5, 2014, 9:07pm UTC](https://forum.ansible.com/t/is-there-a-way-to-make-my-var-less-ugly/16426/3 "2014-10-05T21:07:36Z")

</div>

Thanks, just what I needed.
