发布管道中的Azure Devops日志记录命令 [英] Azure Devops logging commands in release pipeline

查看:35
本文介绍了发布管道中的Azure Devops日志记录命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过将一些env变量设置为一个任务来定制管道发布的输出.我找到以下链接:

I am trying to customize the output of my pipeline release through setting some env variables into a task. I found the following link: https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=powershell

which however does not seem to work. What I am doing is simply to create a pipeline with a single task (either bash or PS), and there declaring the commands specified in the link through the inline version of the task.

Has anyone already successfully managed to make these commands work? Do I do something wrong and/or incomplete?

Does anyone have a better way to customise the pipeline with relevant information from a task? E.g. through the release name, or the description and/or tag of the specific release?

Edit:

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)"

this is the code, copy and pasted. Now I tried also with the script, and it does not work either. I use an hosted windows agent.

解决方案

When you set a new variable with the logging command the variable is available only in the next tasks and not in the same task.

So, split your script to 2 tasks, in the second task put the last 3 lines and you will see that the first task works:

这篇关于发布管道中的Azure Devops日志记录命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆