简体   繁体   中英

How can I set ENVIRONMENT status in Azure DevOps yaml pipeline

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

管道视图

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

管道视图

How can I change that?

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] ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM