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

Ansible plugin not reading environment variables

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          rbbrasil Rodrigo Brasil added a comment -

          Worked when using the GIT_BRANCH env var:

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: