Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45132

Ansible plugin not reading environment variables

      Hello,

       

      I'm trying to read the $BRANCH_NAME env vars in my playbook, just like the Wiki example, but it's empty.

        

      - hosts: "{{ lookup('env','BRANCH_NAME') }}"
        gather_facts: false
      

       

      I'll use the branch name to update some files on target host. Is the any special setup in Ansible or Jenkins for this case? I've tried also with "gather_facts: true" but without success.

          [JENKINS-45132] Ansible plugin not reading environment variables

          Worked when using the GIT_BRANCH env var:

          - hosts: "hosts_{{ lookup('env','GIT_BRANCH') | regex_replace('origin/') }}"

          Rodrigo Brasil added a comment - Worked when using the GIT_BRANCH env var: - hosts: "hosts_{{ lookup( 'env' , 'GIT_BRANCH' ) | regex_replace( 'origin/' ) }}"

            rbbrasil Rodrigo Brasil
            rbbrasil Rodrigo Brasil
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: