Using Powershell for Azure Devops to refer to predefined variables.



Using Powershell for Azure Devops Linux agent to refer to variables can be hard to get right essentially just use $(build.SourceBranchName) - the build.SourceBranchName is what listed in the documentation.

You can see one example given below :-





taskPowerShell@2
      displayName'PowerShell contruct VersionSuffix if not Master'
      inputs:
        targetType'inline'
        script|
         Write-Host "Setting up version info"
         $VersionSuffix =  'prerelease' + '.$(build.SourceBranchName).' + $(build.buildid)
         write-host "##vso[task.setvariable variable=VersionSuffix]$VersionSuffix"
         Write-Output "##vso[build.updatebuildnumber]$($env:VersionPrefix)-$VersionSuffix"

        failOnStderrtrue
      conditionand(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm