issues
search
buguibu
/
ios-notes-issues-lessons
Notes, issues and lessons about my iOS development experience
2
stars
0
forks
source link
Get CURRENT_PROJECT_VERSION and MARKETING_VERSION on Azure Pipelines
#27
Open
buguibu
opened
2 years ago
buguibu
commented
2 years ago
Given an Xcode project using "None" as 'Versioning System' build setting
When I want to know the version of a given target
Then I need to extract it from the target settings in this ugly and weak way:
task: PowerShell@2 displayName: '🚧 Script stuff for prepare 🔖version numebrs' inputs: targetType: 'inline' script: | $target_build_settings = (/usr/bin/xcodebuild -showBuildSettings -json -quiet -target ${{ parameters.appScheme }}) $target_buildVersion_temp = [int]((echo $target_build_settings | Select-String -Pattern '"CURRENT_PROJECT_VERSION" : "[0-9]"' ) -replace '\D+(\d+)\D+','$1' ) $target_buildVersion_temp++ echo "##vso[task.setvariable variable=newBuildVersion;]$target_buildVersion_temp" $newMarketingVersionTemp = (((echo $target_build_settings | Select-String -Pattern '"MARKETING_VERSION" : "[0-9][0-9.]*"') -replace ' "MARKETING_VERSION" : "','' ) -replace '",','') echo "##vso[task.setvariable variable=newMarketingVersion;]$newMarketingVersionTemp"
For use it in next steps
VARIABLES WILL NOT ECHO THE UPDATED VALUE IN THIS STEP
:
task: PowerShell@2 displayName: '🧪 Script stuff for prepare 🐛 Debug🔖version numebrs' inputs: targetType: 'inline' script: | echo "🧪 🧪 🧪 🧪 🧪newBuildVersion 🧪 🧪 🧪 🧪 " echo "newBuildVersion=$(newBuildVersion)" echo "🧪 🧪 🧪 🧪 newMarketingVersion 🧪 🧪 🧪 🧪 " echo "newMarketingVersion=$(newMarketingVersion)"