How can I set ENVIRONMENT status in Azure DevOps yaml pipeline

Viewed 261

I am creating CICD pipeline in Azure Devops.

I have pipeline that has name set dynamically.

name: 'Set dynamically below in a task' 

Then in BUILD stage I update it

[string] $date = (Get-Date -Format 'yyyyMMdd')
[string] $projectVersion = (Get-Content 'version.json') -join "`n" | ConvertFrom-Json | Select -ExpandProperty "version"      
[string] $buildName = "$projectVersion.$(Build.BuildId)+$date.API"     
Write-Host "##vso[build.updatebuildnumber]$buildName"

I have currently 3 stages

  1. Build
    • builds up
    • set build name via VSO command
    • publish artifact
  2. Deploy to DEV
    • download artifact and deploy to dev environment
  3. Deploy to TEST
    • download artifact and deploy to test environment

I am actually using ENVIRONMENT within Azure Devops to track all deployments and here is the problem. While pipeline build number is updated properly in Pipelines view

Pipelines view

when I go to Environments tab the not so updated build name is being displayed.

Pipeline view

How can I change that ?

1 Answers

You can set between different environments, such as

FIRSTENVIRONMENT
echo "##vso[task.setvariable variable=VAR1;isOutput=true;]$VALUE";

SECONDENVIRONEMENT
- job: ‘JOBNAME’
       variables:
         var2: $[ dependencies.Build.outputs[Firstenvironment.VAR1] ]
Related