I set up a Jenkins build that uses the "Publish over SSH" plugin to remotely execute an ansible script, injecting the variables into the call to ansible-playbook
The command that Jenkins will remotely execute:
ansible-playbook /home/username/test/test.yml --extra-vars "ui_version=$UI_VERSION web_version=$WEB_VERSION git_release=$GIT_RELEASE release_environment=$RELEASE_ENVIRONMENT"
Which is triggered by the following curl:
curl -k --user username:secretPassword -v -X POST https://jenkins/job/Ansible_Test/buildWithParameters?UI_VERSION=abc&WEB_VERSION=def&GIT_RELEASE=ghi&RELEASE_ENVIRONMENT=jkl
Which should be utilizing the following variables:
My Problem: only the first parameter gets injected, as you can see on the longest line of the console output on Jenkins below:
...
SSH: EXEC: completed after 201 ms
SSH: Opening exec channel ...
SSH: EXEC: channel open
SSH: EXEC: STDOUT/STDERR from command [ansible-playbook /home/dholt2/test/test.yml --extra-vars "ui_version=abc web_version= git_release= release_environment="] ...
SSH: EXEC: connected
...
It turns out that the terminal was trying to interpret the
&
after the first parameter, as mentioned here. Quoting the URL resulted in a successful transmission and variable injection.I should've known it was the cause when the command waited for more input.