Embrace chaos to achieve stability

Yesterday I required to create the pipeline to publish a zip file to a storage space account on Azure. The zip file is used to create some content to a website. I personally use the Azure DevOps wiki to write the content. A advancement branch, that contains the functioning version, and the master department that contains the particular production edition.

Every time a change is made towards the development branch of the wiki, I want to publish a new version of the zip file to the storage account. In purchase to do this I created a YAML pipeline. However, every time after i want to publish to creation, I merge the modifications from the development wiki plus trigger the same pipeline.

Azure DevOps has a great system to change variables in the various stages.

You can use adjustable groups or stage factors, but for different branches there is absolutely no such thing. After a few googling and puzzling We ended up with a simple inline Powershell script.

switch(${env:BUILD_SOURCEBRANCH}) {
'refs/heads/master' {Write-Host "##vso[task.setvariable variable=publishUrl] }
'refs/heads/development' {Write-Host "##vso[task.setvariable variable=publishUrl] }
default {Write-Host "##vso[task.setvariable variable=publishUrl]NONE"; }
}

The ##vso[task.setvariable variable=publishUrl]NONE format sets a variable within the pipeline that can be used later within the normal way. To learning much more on this please check this link

Eventually my YAML pipeline appeared as if this

pipeline

Hope this particular helps!


Source link