Azure Devops 警告内联 shell 脚本
Azure Dev Ops warnings inline shell script
问题
我正在通过 Azure Dev Ops 管道中的 SSH 在远程计算机上 运行 内联 shell 脚本。根据某些情况,运行管道应该抛出自定义警告。
该功能有效,尽管以一种非常扭曲的方式:当 运行 连接管道时,警告 总是 出现。更准确地说:
- 如果不满足条件,警告出现一次。
- 如果满足条件,警告出现两次。
下面的例子应该清楚地说明了这个问题。
例子
假设我们有以下 .yaml
管道模板。请为您的设置调整 pool
和 sshEndpoint
设置。
pool: 'Default'
steps:
- checkout: none
displayName: Suppress regular checkout
- task: SSH@0
displayName: 'Run shell inline on remote machine'
inputs:
sshEndpoint: 'user@machine'
runOptions: inline
inline: |
if [[ 3 -ne 0 ]]
then
echo "ALL GOOD!"
else
echo "##vso[task.logissue type=warning]Something is fishy..."
fi
failOnStdErr: false
预期行为
因此,上面的 bash 脚本应该回显 ALL GOOD!
因为 3 不是 0。因此,不应触发警告消息。
当前行为
但是,当我在 Azure Dev Ops 中 运行 上面的管道时,步骤日志概述说有一个警告:
日志本身如下所示(连接详细信息已涂黑):
因此,即使代码采用 ALL GOOD!
代码路径,也会出现警告消息。我认为这是因为整个 bash 脚本被回显到日志中 - 但这只是一个假设。
问题
如何确保警告仅在满足条件时才出现在执行的管道中?
看起来像 the SSH task logs the script to the console prior to executing it。您可能可以欺骗日志解析器:
HASHHASH="##"
echo $HASHHASH"vso[task.logissue type=warning]Something is fishy..."
I'd consider it a bug that the script is appended to the log as-as. I've filed an issue.(似乎也进行了一些解析)...
问题
我正在通过 Azure Dev Ops 管道中的 SSH 在远程计算机上 运行 内联 shell 脚本。根据某些情况,运行管道应该抛出自定义警告。
该功能有效,尽管以一种非常扭曲的方式:当 运行 连接管道时,警告 总是 出现。更准确地说:
- 如果不满足条件,警告出现一次。
- 如果满足条件,警告出现两次。
下面的例子应该清楚地说明了这个问题。
例子
假设我们有以下 .yaml
管道模板。请为您的设置调整 pool
和 sshEndpoint
设置。
pool: 'Default'
steps:
- checkout: none
displayName: Suppress regular checkout
- task: SSH@0
displayName: 'Run shell inline on remote machine'
inputs:
sshEndpoint: 'user@machine'
runOptions: inline
inline: |
if [[ 3 -ne 0 ]]
then
echo "ALL GOOD!"
else
echo "##vso[task.logissue type=warning]Something is fishy..."
fi
failOnStdErr: false
预期行为
因此,上面的 bash 脚本应该回显 ALL GOOD!
因为 3 不是 0。因此,不应触发警告消息。
当前行为
但是,当我在 Azure Dev Ops 中 运行 上面的管道时,步骤日志概述说有一个警告:
日志本身如下所示(连接详细信息已涂黑):
因此,即使代码采用 ALL GOOD!
代码路径,也会出现警告消息。我认为这是因为整个 bash 脚本被回显到日志中 - 但这只是一个假设。
问题
如何确保警告仅在满足条件时才出现在执行的管道中?
看起来像 the SSH task logs the script to the console prior to executing it。您可能可以欺骗日志解析器:
HASHHASH="##"
echo $HASHHASH"vso[task.logissue type=warning]Something is fishy..."
I'd consider it a bug that the script is appended to the log as-as. I've filed an issue.(似乎也进行了一些解析)...