Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set an VSTS Build variable in a Build Step so that the value can be used in a subsequent Build Step?

I'm currently using Build in Visual Studio Team Services (was Visual Studio Online), and would like to be able to set a Build Variable in a Build Step so that the new value can be used in a subsequent Build Step.

Obviously you can set it before the Build starts but I'm looking to late bind the variable during a subsequent Build Step.

Is this possible?enter image description here

like image 736
Simian Avatar asked Oct 01 '15 07:10

Simian


People also ask

How do I set variables in Azure DevOps release pipeline?

You define and manage these variables in the Variables tab in a release pipeline. In the Pipeline Variables page, open the Scope drop-down list and select "Release". By default, when you add a variable, it is set to Release scope. Share values across all of the tasks within one specific stage by using stage variables.

How is the variables in variable group accessed in Azure DevOps build release definition?

To use a variable group, open your pipeline. Select Variables > Variable groups, and then choose Link variable group. In a build pipeline, you see a list of available groups. In a release pipeline, for example, you also see a drop-down list of stages in the pipeline.

How do I pass a variable from one task to another in Azure DevOps?

Share variables between Tasks across the Jobs (of the same Stage) We need to use the isOutput=true flag when you desire to use the variable in another Task located in another Job.

What are environment variables in VSTs build/release?

When using VSTS Build/Release pipelines, we can run Powershell and other scripts as part of execution. Typically we have defined Environment Variables for these pipelines that allow us to share common information between Tasks (e.g. - Environment Name, Resource Group, etc.)

Do I have to send PowerShell arguments to VSTs?

I don’t have to send PowerShell arguments as I can access my variables that I set them in the VSTS build, the access here by calling them in the PowerShell script. For example in our scenario, I set variable domain.username to access it within script, I need to transfer “.” to “_” so I have call it as $env:domain_username

What information is required to queue a VSTs project?

Commit ID of the branch to build. ID of the definition to queue. Required if --name is not supplied. Name of the definition to queue. Ignored if --id is supplied. Automatically detect instance and project. Default is "on". VSTS account or TFS collection URL.

How to use environment variables in a build?

How to: Use environment variables in a build. When you build projects, it is often necessary to set build options using information that is not in the project file or the files that comprise your project. This information is typically stored in environment variables.


1 Answers

When inside of a script you can update a variable by emitting the following in your ps1

"##vso[task.setvariable variable=testvar;]testvalue" 

You can then pass the variable into the next script using $(testvar)

like image 100
MrHinsh - Martin Hinshelwood Avatar answered Sep 18 '22 17:09

MrHinsh - Martin Hinshelwood