我设置了一个使用"通过SSH发布"插件远程执行ansible脚本,将变量注入到ansible-playbook
Jenkins将远程执行的命令:
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"
由以下卷曲触发:
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
哪个应该使用以下变量:
我的问题:只会注入第一个参数,如下面Jenkins控制台输出的最长行所示:
...
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
...
答案 0 :(得分:0)
It turns out that the terminal was trying to interpret the aggregate
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.