2
votes

I'm using Azure DevOps on a vs2017-win2016 build agent to provision some infrastructure using Terraform.

What I want to know is it possible to pass the Terraform Output of a hosts dynamically assigned IP address to a 2nd Job running a different build agent.

I'm able to pass these to build variables in the first Job BASTION_PRIV_IP=x.x.x.x BASTION_PUB_IP=1.1.1.1

But un-able to get these variables to appear to be consumed with the second build agent running ubuntu-16.04 I am able to pass any static defined parameters like Azure Resource Group name that I define before the job start, its just the dynamically assigned ones.

1

1 Answers

5
votes

This is pretty easily done when you are using the YAML based builds. It's important to know that variables are only available within the scope of current job by default. However you can set a variable as an output variable for your job. This output variable can then be mapped to a variable within second job (do note that you need to set the first job as a dependency for the second job).

Please see the following link for an example of how to get this to work

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#set-a-multi-job-output-variable

It may also be doable in the visual designer type of build, but i couldn't get that to work in the quick test i did, maybe you can get something to work inspired on the linked example.