vsts-arm-outputs icon indicating copy to clipboard operation
vsts-arm-outputs copied to clipboard

Setting variables as output variables

Open mmajcica opened this issue 4 years ago • 2 comments

I have a case where I need to get a variable in a separate jobs where I do run the ARM Output task. As I can judge from the following line of code

https://github.com/keesschollaart81/vsts-arm-outputs/blob/912497cd5d3384929ba28175712bb452af84aa0d/arm-outputs/arm-outputsV2/index.ts#L58

the task outputs always all of the variables as no output variables.

I would like to be able to modify this behavior by a flag on a task itself.

If you agree, a quick PR will come in.

Thanks

mmajcica avatar Feb 25 '21 17:02 mmajcica

I made a test to be sure of this.

Case 1 - isOutput is set to true

pool:
  vmImage: ubuntu-latest

jobs:

# Set an output variable from a deployment
- deployment: A
  environment: staging
  strategy:
    runOnce:
      deploy:
        steps:
        - bash: echo "##vso[task.setvariable variable=myOutputVar;isOutput=true]this is the deployment variable value"
          name: setvarStep
        - bash: echo $(setvarStep.myOutputVar)
          name: echovar

# Map the variable from the job for the first slice
- deployment: B
  dependsOn: A
  environment: staging
  variables:
    myVarFromDeploymentJob: $[ dependencies.A.outputs['A.setvarStep.myOutputVar'] ]
  strategy:
    runOnce:
      deploy:
        steps:
        - bash: "echo $(myVarFromDeploymentJob)"
          name: echovar

And once I run it I do get the following: image

Case 2 - isOutput is set to false

pool:
  vmImage: ubuntu-latest

jobs:

# Set an output variable from a deployment
- deployment: A
  environment: staging
  strategy:
    runOnce:
      deploy:
        steps:
        - bash: echo "##vso[task.setvariable variable=myOutputVar;isOutput=false]this is the deployment variable value"
          name: setvarStep
        - bash: echo $(setvarStep.myOutputVar)
          name: echovar

# Map the variable from the job for the first slice
- deployment: B
  dependsOn: A
  environment: staging
  variables:
    myVarFromDeploymentJob: $[ dependencies.A.outputs['A.setvarStep.myOutputVar'] ]
  strategy:
    runOnce:
      deploy:
        steps:
        - bash: "echo $(myVarFromDeploymentJob)"
          name: echovar

And once I run it I do get the following: image

mmajcica avatar Feb 25 '21 17:02 mmajcica

Hey, any progress on that?

PiotrWachulec avatar Apr 21 '22 14:04 PiotrWachulec