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





- task: PowerShell@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"

        failOnStderr: true
      condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))

Comments

Popular posts from this blog

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

llama cpp running it in google colab