发布管道中的 Azure Devops 日志记录命令
Azure Devops logging commands in release pipeline
我正在尝试通过将一些环境变量设置到任务中来自定义管道发布的输出。
我发现了以下 link:
https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=powershell
但这似乎不起作用。
我所做的只是创建一个包含单个任务(bash 或 PS)的管道,并通过任务的内联版本声明 link 中指定的命令。
有没有人已经成功地使这些命令起作用?
我做错了吗and/or不完整?
有没有人有更好的方法来使用任务中的相关信息自定义管道?例如。通过版本名称,或特定版本的描述 and/or 标签?
编辑:
Write-Host "##vso[task.setvariable variable=sauce;]crushed tomatoes"
Write-Host "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
Write-Host "Non-secrets automatically mapped in, sauce is $env:SAUCE"
Write-Host "Secrets are not automatically mapped in, secretSauce is $env:SECRETSAUCE"
Write-Host "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
这是代码,复制并粘贴。现在我也尝试了脚本,但它也不起作用。
我使用托管 windows 代理。
当您使用日志记录命令设置新变量时,该变量仅在 下一个 任务中可用,而不在同一任务中可用。
因此,将您的脚本拆分为 2 个任务,在第二个任务中放入最后 3 行,您将看到第一个任务有效:
我正在尝试通过将一些环境变量设置到任务中来自定义管道发布的输出。 我发现了以下 link: https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=powershell
但这似乎不起作用。 我所做的只是创建一个包含单个任务(bash 或 PS)的管道,并通过任务的内联版本声明 link 中指定的命令。
有没有人已经成功地使这些命令起作用? 我做错了吗and/or不完整?
有没有人有更好的方法来使用任务中的相关信息自定义管道?例如。通过版本名称,或特定版本的描述 and/or 标签?
编辑:
Write-Host "##vso[task.setvariable variable=sauce;]crushed tomatoes"
Write-Host "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
Write-Host "Non-secrets automatically mapped in, sauce is $env:SAUCE"
Write-Host "Secrets are not automatically mapped in, secretSauce is $env:SECRETSAUCE"
Write-Host "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
这是代码,复制并粘贴。现在我也尝试了脚本,但它也不起作用。 我使用托管 windows 代理。
当您使用日志记录命令设置新变量时,该变量仅在 下一个 任务中可用,而不在同一任务中可用。
因此,将您的脚本拆分为 2 个任务,在第二个任务中放入最后 3 行,您将看到第一个任务有效: