My azure pipelines yaml runs a powershell script which is stored inside the repo.
That powershell script expects 3 variables : the working directory, the Oauth access token and the source branch name (which triggered the pipeline).
But it seems , whenever I try to pass on parameters, the powershell script does not recognize them and I get an error
The term 'env:SYSTEM_ACCESSTOKEN' is not recognized as the
name of a cmdlet, function, script file, or operable program
The term 'env:BUILD_SOURCEBRANCHNAME' is not recognized as the
name of a cmdlet, function, script file, or operable program
My yaml looks like this:
name: $(Build.DefinitionName)_$(Build.SourceBranchName)_$(Build.BuildId)
trigger:
branches:
include:
- '*'
variables:
system_accesstoken: $(System.AccessToken)
jobs:
- job: NoteBookMergeAndOnPremSync
displayName: Merge Notebooks to Notebooks branch and sync to on prem git
pool:
name: Poolname
steps:
- task: PowerShell@2
displayName: 'Merge to Notebooks branch in Azure and Sync to On Prem'
inputs:
targetType: filePath
filePath: ./deploy/MergeAndSync.ps1
arguments: '-workingdir $(System.DefaultWorkingDirectory)\ -featurebranch $(env:BUILD_SOURCEBRANCHNAME) -accesstoken $(env:SYSTEM_ACCESSTOKEN)'
I was able to run the powershell script successfully as an "in line powershell script" when using a "release definition" using the GUI, but I would like all that to be in an azure pipeline (yaml)in yaml but unfortunately, I just can't find a way to pass on these env variables.
How do I pass on the BUILD_SOURCEBRANCHNAME and env:SYSTEM_ACCESSTOKEN to the powershell script from the azure pipeline yaml?
Also, I would like to avoid an "inline powershell script" and rather have the logic saved in my repo.