我正在使用Azure管道变量来为命令构造一组参数.我必须用于Azure管道的变量类型为宏格式(例如 $(var)),您可以在此处查看其详细信息: docs.microsoft/en-us/azure/devops/pipelines/process/variables?view = azure-devops&stab = yaml%2Cbatch#runtime-expression-syntax
I am using Azure pipelines variables to construct a set of parameters for a command. The type of variable I must use for Azure pipelines is in macro format (like $(var)), you can see the details of it here: docs.microsoft/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#runtime-expression-syntax
如果 $(var)不包含值,则不打印"nothing",而是打印 $(var)
If $(var) does not contain a value, instead of printing "nothing", it will print $(var)
当我运行命令并且未传递该值时,屏幕上会提示错误,提示未找到该命令.目前,这没什么大不了的,它不会出错我下面的命令集,但是我希望至少能抑制它.
When I run my command and that value isn't passed in, an error prompts on the screen that command was not found. At the moment it's not a big deal, it doesn't error my following set of commands, but I was hoping to suppress it at the very least.
VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)" if [ ${#VAR_TERRAFORMDESTROY} -ge 1 ]; then VAR_TERRAFORMDESTROY="yes" else VAR_TERRAFORMDESTROY="no" fi在日志输出中,它将打印/vsts/_work/_temp/4e426335-0930-4375-b05c-c4dbbcb38139.sh:第5行:TERRAFORMDESTROY:未找到命令
In the logs output it will print /vsts/_work/_temp/4e426335-0930-4375-b05c-c4dbbcb38139.sh: line 5: TERRAFORMDESTROY: command not found
我尝试了 VAR_TERRAFORMDESTROY =" $(TERRAFORMDESTROY)".>/dev/null 2>& 1 ,但是因为>/dev/null 2>& 1 不在方括号()内,它不会将结果输出为null.由于Azure YAML变量的工作原理,它不能放在方括号内.
I have tried VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)" > /dev/null 2>&1, but because > /dev/null 2>&1 is not inside the brackets (), it will not output the result to null. And it cannot be inside the brackets due to how Azure YAML variables work.
请问有人可以建议抑制我找不到的命令输出吗?
Can anyone suggest anything to suppress the command not found output for me, please?
推荐答案
请问有人可以抑制我找不到的命令吗?
Can anyone suggest anything to suppress the command not found output for me, please?
禁止显示组错误消息
{ VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)"; } > /dev/null 2>&1更多推荐
输出命令为空
发布评论