Motivation
while creating a build, in my workplace we usually pull all the latest changes in local and then run few git commands and then change those values in the build pipeline,
Automation:
- Use Azure bash task to run the git commands
- Store the results in some variables and then use that in other tasks,
How to use bash tasks to store the variable
echo "------------ Output Results ----------------"
echo "build version of the 8 characters: ${PBuildVersionFirst} "
echo "build version with 4 character : ${PBuildVersionSecond} "
# here we are storing variable PBuildVersionFirst in the variable PBuildVersionFirst1 and #then use it other tasks
echo "##vso[task.setvariable variable=PBuildVersionFirst1]${PBuildVersionFirst}"
echo "##vso[task.setvariable variable=PBuildVersionFirst2]${PBuildVersionSecond}"
How to use the above variable in PowerShell Script tasks ?
Write-Host $(PBuildVersionFirst1)
Write-Host $(PBuildVersionFirst2)
How to use the above variable in bash script tasks?
echo $(PBuildVersionFirst1)
echo $(PBuildVersionFirst2)
Next Steps :
Use this variable in the Gradle task and then generate the build artifact :)