microsoft / azure-pipelines-yaml

Azure Pipelines YAML examples, templates, and community interaction
MIT License
1.19k stars 924 forks source link

Pass variables from Build pipeline to Release #609

Closed sjdhanasekaran closed 1 week ago

sjdhanasekaran commented 2 months ago

I have traced many articles but not getting clear idea.

I am using azure build pipeline to set a variables and consume the same variable in azure releases by point the build as artifact in releases.

trigger:
  - base

pool:
  name: Default

steps:
  - checkout: self
    persistCredentials: true

  - task: Bash@3
    displayName: "SetVer"
    name: "SetVer"
    enabled: true
    inputs:
      targetType: "inline"
      script: |
        echo "##vso[task.setvariable variable=baseImageTag;isOutput=true]1.0.0"

  - task: Bash@3
    displayName: "printVer"
    enabled: true
    inputs:
      targetType: "inline"
      script: |
        echo "echoinggg"
        echo $(SetVer.baseImageTag)

in the second task i am able to consume the baseImageTag but the same variable i am not able to consume in releases.

Thanks all

ivanduplenskikh commented 1 month ago

Hi @sjdhanasekaran, The values of pipeline variables can vary between different runs or jobs as it stated in the documentation

The value of a variable can change from run to run or job to job of your pipeline.

If you're using a release pipeline, therefore you have no access to YAML pipeline's variables and their values.

If you need to use a pipeline variable, you may use another deployment strategy, such as defining a deployment stage in a YAML pipeline

sjdhanasekaran commented 1 week ago

@ivanduplenskikh Clear. Thanks