Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference Xcode version number from Jenkins

Tags:

xcode

ios

jenkins

I'm trying to get a reference to my Xcode projects CFBundleVersionString or CFBundleVersion within my Jenkins Build.

My goal is to be able to set the build numbers in this sort of fashion ${CFBundleVersionString}.${build_number}. This way the Version is dictated by the project and the build number is added on when the project is built.

Is this possible at all? I know that you can reference ${build_number}. Also I know that I could include a parameter in the build that is dictated, but I would prefer it all be managed through the Xcode project since our builds are triggered by github commits.

like image 617
James Parker Avatar asked Jul 02 '14 16:07

James Parker


2 Answers

You can read CFBundleVersionString from your Info.plist file with:

export VERSION=`defaults read ${INFO_PLIST} CFBundleVersionString`

output this to a property file:

echo VERSION=$VERSION > version.properties

and use this file to inject environment variables to your jenkins build. You can then use this variable with Build Name Setter plugin or simply us it in build mails.

Similarly you can update the version inside the plist with:

defaults write ${INFO_PLIST} CFBundleVersionString ${VERSION}.${BUILD_NUMBER}
like image 106
antweiss Avatar answered Sep 29 '22 14:09

antweiss


If you are using the Xcode Plugin, you have CFBundleVersion available as $VERSION and CFBundleShortVersionString as $SHORT_VERSION.

I found $SHORT_VERSION by searching the XCode Plugin source code.

like image 33
cohen72 Avatar answered Sep 29 '22 15:09

cohen72