Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

azure devops - How to get the variable value in TFS/AzureDevOps from Build to Release Pipeline?

I've defined a variable in my TFS/AzureDevops Build definition (say it's time) and assign the value using PowerShell task within my build definition.

Like,

Type: Inline Script.

Inline script:

$date=$(Get-Date -Format g);
Write-Host "##vso[task.setvariable variable=time]$date"

You can refer to this similar example

Now I want to get this value in my release definition pipeline. I configured this build definition as continuous deployment to my release definition.

My Question is

How can I get the value of time in my release definition using some other variable? Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The is no official way to pass variables from Build to Release. The only way to accomplish this is to store the values in a file (json, xml, yaml, what have you) and attach that as a Build Artifact. That way you can read the file in the release and set the variable again.

Martin Hinshelwood seems to have gotten frustrated enough by this problem and turned that functionality into an extension for Azure DevOps Pipelines.

Tasks included

  • Variable Save Task - During your build you can save the variables to a json file stored with your other build assets
  • Variable Load Task - During your Release you can load the saved variables and gain access to them.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...