I was wondering about that. I *did* try that earlier (with so many other 
combinations as well.) This is what I have now:

      debug: var=jenkinsStatus.json.changeSet.items[0].comment

result:

    "jenkinsStatus.json.changeSet.items[0].comment": "{{ 
jenkinsStatus.json.changeSet.items[0].comment }}"

I can’t figure out what’s wrong with that statement, though.


On February 10, 2014 at 2:08:28 PM, Michael DeHaan (mich...@ansible.com) wrote:

It seems like you need to index your array like so:

jenkinsStatus.json.changeSet.items[0].comment 

Since the ".0." would be looking for a hash member named "0" versus an array 
index.




On Mon, Feb 10, 2014 at 2:02 PM, Brent Langston <brent...@oufan.com> wrote:
I'm sure this is probably something I'm doing wrong, but I can't seem to figure 
out the right thing, so hopefully someone else can.

This is the value of the registered variable "jenkinsStatus": 
http://hastebin.com/cacusiwiki.tex

Given the following playbook:

---
- name: Jenkins Status Info
  hosts: localhost
  connection: local
  user: root
  gather_facts: False
  vars:
    jenkins_url: http://jenkins.example.com:8080/job/
    project: member-web-dev

  tasks:

    - name: Get jenkins status
      uri: url={{ jenkins_url }}/{{ project }}/lastBuild/api/json 
return_content=yes status_code=200
      register: jenkinsStatus

    - name: show the output
      debug: var=jenkinsStatus.json.changeSet.items.0.comment

I'm trying to access the comment data, but am not getting back any value:
ok: [127.0.0.1] => {
    "jenkinsStatus.json.changeSet.items.0.comment": "{{ 
jenkinsStatus.json.changeSet.items.0.comment }}"
}

and if I just use debug: var=jenkinsStatus.json.changeSet.items

ok: [127.0.0.1] => {
    "jenkinsStatus.json.changeSet.items": "<built-in method items of dict 
object at 0x7fd259a89ae0>"
}

So how can I access/use the value stored in comment?

> ansible-playbook --version
ansible-playbook 1.5,
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to