ArgoWorkflow模板参数异常:pre-conditions子步骤无法获取host参数
问题原因分析
你的online-check模板中的Python脚本存在语法错误:print({{inputs.parameters.host}})在渲染后会将host值直接作为裸字符串输出(比如print(server1)),而Python会把server1视为未定义变量,导致脚本执行失败,表现为参数“无法获取”。
解决方案
修改online-check模板的脚本部分,给print的参数添加引号,确保渲染后是合法的Python字符串输出:
- name: online-check inputs: parameters: - name: host script: image: python:alpine3.6 command: - python source: | print("{{inputs.parameters.host}}")
另外,建议在pre-conditions模板传递参数时也加上引号,避免因host值包含特殊字符导致YAML解析问题:
- name: pre-conditions inputs: parameters: - name: host steps: - - name: online-check template: online-check arguments: parameters: - name: host value: "{{inputs.parameters.host}}"
验证方式
修改后重新提交Workflow,查看online-check步骤的日志,应该能正常打印出host的值,说明参数已正确传递并解析。
内容的提问来源于stack exchange,提问作者Ray Gao
相关产品推荐
相关产品推荐

