Reputation: 81
We're using VSTS to build and release our front end code (JS + WebPack)
We now have 2 separate builds for Dev and Test.
Build tasks:
(+release pipelines)
In the "Triggers" section in VSTS, it is posible to listen to multiple branches.
It seems unnecessary to have to so similar builds (?) when we have individual release pipelines.
The only different is step 3 (npm build dev and npm build test)
My question is: Is it possible to dynamically at build time determin the build environment based on source branch that triggered the build? And dynamically set arg in step 3?
Upvotes: 1
Views: 406
Reputation: 81
Thank you @starian :+1:
Ended up creating a branch selector shell script (.sh)
The script
VSTS Build tasks
VSTS Triggers (default development)
Upvotes: 0
Reputation: 33698
Sure, you can add a PowerShell task to check source branch (using built-in variable, such as Build.SourceBranch), then add or modify the variable through Logging Commands (e.g. Write-Host "##vso[task.setvariable variable=currentEnv;]Dev"
).
After that you can use that variable (currentEnv) in npm task (e.g. Command and arguments: run $(currentEnv)
)
Upvotes: 1