Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Azure devops pipeline does not pass variables to stages #20689

Closed
4 of 7 tasks
scholtz opened this issue Nov 25, 2024 · 4 comments
Closed
4 of 7 tasks

[BUG]: Azure devops pipeline does not pass variables to stages #20689

scholtz opened this issue Nov 25, 2024 · 4 comments
Assignees
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug

Comments

@scholtz
Copy link

scholtz commented Nov 25, 2024

New issue checklist

Task name

No response

Task version

No response

Issue Description

We want to create variable in the build stage and use the variable in all deployment stages.

We are able to create variable in the first stage, and pass it to the dev environment. But we are not able to pass the variable from either build stage to the 3rd stage (test) nor from the deployment to dev stage to deployment to test stage.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

ubuntu

Relevant log output

2024-11-25T17:19:36.8830621Z echo "Received variable from Dev: "

Full task logs with system.debug enabled

[build-variable.txt](https://github.com/user-attachments/files/17906739/build-variable.txt)
[deploy-to-dev.txt](https://github.com/user-attachments/files/17906740/deploy-to-dev.txt)
[deploy-to-test.txt](https://github.com/user-attachments/files/17906741/deploy-to-test.txt)
  

Repro steps

trigger:
- none

stages:
- stage: Build
  displayName: Build Stage
  jobs:
  - job: BuildJob
    displayName: Build Job
    steps:
    - script: |
        echo "##vso[task.setvariable variable=myVar;isOutput=true]Hello from Build"
      name: OutputStep

- stage: DeployDev
  displayName: Deploy Dev Stage
  dependsOn: Build
  variables:
    myVarFromBuild: $[ stageDependencies.Build.BuildJob.outputs['OutputStep.myVar'] ]
  jobs:
  - deployment: DeployJob
    displayName: Deploy to Dev
    environment: "Dev"
    strategy:
      runOnce:
        deploy:
          steps:
          - script: |
              echo "Received variable from Build: $(myVarFromBuild)"
              echo "##vso[task.setvariable variable=myVarDev;isOutput=true]$(myVarFromBuild)"
            name: SetOutputForDev

- stage: DeployTest
  displayName: Deploy Test Stage
  dependsOn: DeployDev
  variables:
    myVarFromDev: $[ stageDependencies.DeployDev.DeployJob.outputs['SetOutputForDev.myVarDev'] ]
  jobs:
  - deployment: DeployJob
    displayName: Deploy to Test
    environment: "Test"
    strategy:
      runOnce:
        deploy:
          steps:
          - script: |
              echo "Received variable from Dev: $(myVarFromDev)"
@scholtz
Copy link
Author

scholtz commented Dec 2, 2024

Is there any timeline to fix this bug?

@hrnjan
Copy link

hrnjan commented Dec 2, 2024

We are also experiencing the same issue described here by @scholtz

@scholtz
Copy link
Author

scholtz commented Dec 9, 2024

@ericsciple @davidstaheli @DmitriiBobreshev Is there some way how to work with this? My goal is to build applications using build pipelines, and then deploy 10 applications at once to the test environment. When they are properly tested they should be deployed to prod environment. However this does not work as in the prod environment we dont have proper build info if something else was built meanwhile.. This seems to be so basic functionality that either we are missing some basic config or the azure pipelines has serious critical bug.

Btw we can solve this using the release pipelines, however there is bad management of the source of the pipes and we would like to prefer to use the build pipelines as it seems to be the future.

@v-schhabra v-schhabra added Area: ABTT Akvelon Build Tasks Team area of work and removed Area: Release labels Dec 17, 2024
@praval-microsoft
Copy link
Collaborator

  1. Build to DeployTest

You need to explicitly add a dependency on Build stage for the variables to be accessible. Ref : FAQ

  1. DeployDev to DeployTest

Your syntax is incorrect, it should be :
myVarFromDev: $[ stageDependencies.DeployDev.DeployJob.outputs['DeployJob.SetOutputForDev.myVarDev'] ]

Ref : Deployment Jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug
Projects
None yet
Development

No branches or pull requests

4 participants