【问题标题】:How do you print conditional debug statements from an Azure DevOps YAML file?如何从 Azure DevOps YAML 文件打印条件调试语句?
【发布时间】:2020-04-06 17:06:40
【问题描述】:

启用调试/诊断时,您会在 Azure Pipeline 日志中看到所有这些条件调试语句。

##[debug]   -NoLogo
##[debug]   -NoProfile
##[debug]   -NonInteractive
##[debug]   -Command

但是如何从 PipeLine YAML 文件、脚本或程序中打印这些? 我看到了通过 powershell 在 Azure PipeLines Logging Commands Documentation 中记录警告和错误的示例。

echo "##vso[task.logissue type=error]Something went very wrong."
echo "##vso[task.logissue type=warning;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]Found something that could be a problem."

但没有条件调试详细语句。

【问题讨论】:

    标签: azure-devops


    【解决方案1】:

    Azure DevOps 中的日志是自动解析的。检查以下示例:

    # Write your powershell commands here.
    
    Write-Host "##[section] This is colored green!"
    Write-Host "##[command] This is colored blue!"
    Write-Host "##[debug] This is colored gray!"
    Write-Host "##[warning] This is a warning!"
    Write-Host "##vso[task.logissue type=warning;]This is another warning" 
    Write-Host "##[error] This is an error!"
    Write-Host "##vso[task.logissue type=error;]This is another error"
    

    【讨论】:

      猜你喜欢
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2021-03-25
      • 2022-12-13
      • 2021-12-31
      • 2020-08-26
      • 2021-06-04
      相关资源
      最近更新 更多