Hello,

Yes, the variables are available as env vars inside the process running 
ansible. If you want to access these env vars within an ansible playbook 
you should use the lookup plugin as showed here in the ansible 
FAQ: 
http://docs.ansible.com/ansible/faq.html#how-do-i-access-shell-environment-variables

You should then adapt your playbook (I tested and it works for me)

---
- hosts: all
  tasks:
    - command: echo "{{ lookup('env','PATH') }}"
      register: default_path
    - command: echo "{{ lookup('env','WORKSPACE') }}"
      register: jenkins_job_workspace

Hope it helps.

Le mardi 12 juillet 2016 18:15:47 UTC+2, Ricardo Hernandez a écrit :
>
> Hi,
>
> Starting from version 0.5 of the Ansible Plugin the build environment 
> variables are available during ansible execution. 
> I'm currently trying to get the job workspace path inside my playbook 
> (which I provide using job DSL) the following way:
>
> ---
> - hosts: all
>   tasks:
>     - command: echo "$PATH"
>       register: default_path
>     - command: echo "$WORKSPACE"
>       register: jenkins_job_workspace
>
>
> However, WORKSPACE doesn't seem to be defined, as shown in the output:
>
> TASK [command] 
> ***************************************************************** 
> changed: [10.100.198.9] => {"changed": true, "cmd": ["echo", "$PATH"], 
> "delta": "0:00:00.002428", "end": "2016-07-12 10:49:02.252685", "rc": 0, 
> "start": "2016-07-12 10:49:02.250257", "stderr": "", "stdout": 
> "/usr/local/bin:/usr/bin", "stdout_lines": ["/usr/local/bin:/usr/bin"], 
> "warnings": []} 
> TASK [command] 
> ***************************************************************** 
> changed: [10.100.198.9] => {"changed": true, "cmd": ["echo", "$WORKSPACE"], 
> "delta": "0:00:00.002479", "end": "2016-07-12 10:49:02.470880", "rc": 0, 
> "start": "2016-07-12 10:49:02.468401", "stderr": "", "stdout": "$WORKSPACE", 
> "stdout_lines": ["$WORKSPACE"], "warnings": []}
>
> Is this the correct way to access them?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a79544db-0b9a-4d59-a03e-0aca1fc05f99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to