我有一本包含以下任务的可笑剧本,当我运行它时,出现错误:
tasks:
- shell: timeout 5 ps aux | grep app
register: result
ignore_errors: True
- name: Run your shell command
shell: "(ssh -o StrictHostKeyChecking=no abc.com 'ls -1 /var/lib/jenkins/workspace/copy/stuff/*' | parallel -j20 'scp -o StrictHostKeyChecking=no abc.com:{} /data/records/')"
when: result.rc != 124 && result.rc != 0
错误是:
{"msg": "The conditional check 'result.rc != 124 && result.rc != 0' failed. The error was: template error while templating string: unexpected char u'&' at 23. String: {% if result.rc != 124 && result.rc != 0 %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/var/lib/jenkins/workspace/proc/test.yml': line 10, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: copy files\n ^ here\n"}
你知道我在做什么错吗?
答案 0 :(得分:2)
正确的语法是
when:
- result.rc != 124
- result.rc != 0
或
when: (result.rc != 124) and (result.rc != 0)