Azure Devops logging commands in release pipeline

此生再无相见时 提交于 2021-02-05 08:34:21

问题


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.


回答1:


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:



来源:https://stackoverflow.com/questions/56749136/azure-devops-logging-commands-in-release-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!