Variable not working in CICD job

I am running GitLab 13.0 and adding a job which uses a variable called $TOWER_PASS created in the web UI. This pipeline uses this variable successfully in the deploy stage to call an Ansible Tower job. However, when I want to run a similar command in the test stage, the command fails and says awx: argument --conf.password: expected one argument which to me says it’s not passing in the variable properly. Why would this work in the deploy stage but not test stage?

lab_check:
  stage: test
  script:
    - pip install https://releases.ansible.com/ansible-tower/cli/ansible-tower-cli-latest.tar.gz
    - awx --conf.host $TOWER_URL --conf.username $TOWER_USER --conf.password $TOWER_PASS --conf.insecure job_templates launch 'CICD Lab Check'
  tags:
    - ci
    - network

ansible_tower_trigger:
  stage: deploy
  script:
    - pip install https://releases.ansible.com/ansible-tower/cli/ansible-tower-cli-latest.tar.gz
    - awx --conf.host $TOWER_URL --conf.username $TOWER_USER --conf.password $TOWER_PASS --conf.insecure job_templates launch 'Network Configuration'
  tags:
    - ci
    - network
  only:
    - master

Hi,

where are these variables defined? To rule out a specific naming filter, does the error happen as well when you remove the password parameter and check the rest?

Cheers,
Michael

I forgot to mention I fixed this. The variable was setup to only be injected for protected branches. Thank you!

1 Like