我正在運行一個安裝jenkins的腳本,需要運行cli.jar來運行多個腳本。它需要jnlp端口,我希望通過可靠的shell命令進行設置。但它似乎失敗了。如何通過命令行在jenkins中設置jnlp端口?
- name: Set jnlp port
shell: 'curl -X POST -d ".useSecurity=on&slaveAgentPort.type=fixed&value=49187&core%3Aapply=true&json=%7B%22useSecurity%22%3A+%7B%22slaveAgentPort%22%3A+%7B%22type%22%3A+%22fixed%22%2C+%22value%22%3A+%2249187%22%7D%7D%2C+%22core%3Aapply%22%3A+%22true%22%7D" --header "Content-Type:application/x-www-form-urlencoded" http://localhost:8080//configureSecurity/configure'
remote_user: jenkins
become: yes
become_method: sudo
與-vvv選項運行提供了:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/vagrant/ansible/roles/jenkins1.648/tasks/plugins.yml': line 37, column 370, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Check update center and push it to the update URL
shell: 'curl -X POST -d .useSecurity=on&slaveAgentPort.type=fixed&value=49187&core%3Aapply=true&json=%7B%22useSecurity%22%3A+%7B%22slaveAgentPort%22%3A+%7B%22type%22%3A+%22fixed%22%2C+%22value%22%3A+%2249187%22%7D%7D%2C+%22core%3Aapply%22%3A+%22true%22%7D" --header "Content-Type:application/x-www-form-urlencoded" http://localhost:8080//configureSecurity/configure' -vvv
^here
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
Or equivalently:
when: "'ok' in result.stdout"
We could be wrong, but this one looks like it might be an issue with
unbalanced quotes. If starting a value with a quote, make sure the
line ends with the same set of quotes. For instance this arbitrary
example:
foo: "bad" "wolf"
Could be written as:
foo: '"bad" "wolf"'
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
@techraf:是的,當我只是嘗試從命令行運行它的時候呢 –
@techraf我在curl命令結束後添加-vvv。你能詳細說明你如何期待它是 –
好吧,我只想在jenkins中設置TCP/jnlp端口,並且相同的curl命令可以直接正常工作,但不能與正確的工作正常工作。我正試圖找到一個解決方案,爲什麼它失敗了。 –