Created
September 26, 2012 15:57
-
-
Save groupsky/3788849 to your computer and use it in GitHub Desktop.
Android build that produces output file with attached version from manifest when building on jenkins. The manifest version is updated so any -SNAPSHOT suffix is replaced by the build number and the versionCode is updated with build number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="custom_rules"> | |
<!-- ******************************************************* --> | |
<!-- ******************* Other Properties ****************** --> | |
<!-- ******************************************************* --> | |
<property environment="jenkins-env"/> | |
<!-- ******************************************************* --> | |
<!-- ***************** Overriden targets ******************* --> | |
<!-- ******************************************************* --> | |
<target name="-pre-build" depends="-update-manifest-version" /> | |
<target name="-post-build" depends="-rename-output-file" /> | |
<!-- ******************************************************* --> | |
<!-- ***************** Build enhanchment targets *********** --> | |
<!-- ******************************************************* --> | |
<target name="-update-manifest-version" if="jenkins-env.BUILD_NUMBER"> | |
<echo>Updating version name and code in AndroidManifest.xml</echo> | |
<replaceregexp file="AndroidManifest.xml" match="android:versionName="(.*)-SNAPSHOT"" replace="android:versionName="\1.${jenkins-env.BUILD_NUMBER}""/> | |
<replaceregexp file="AndroidManifest.xml" match="android:versionCode=".*"" replace="android:versionCode="${jenkins-env.BUILD_NUMBER}""/> | |
</target> | |
<target name="-retrieve-project-version" depends="-update-manifest-version"> | |
<xpath input="AndroidManifest.xml" expression="/manifest/@android:versionName" output="manifest.version" /> | |
<echo>Project version: ${manifest.version}</echo> | |
</target> | |
<target name="-rename-output-file" depends="-retrieve-project-version" if="jenkins-env.BUILD_NUMBER"> | |
<pathconvert property="out.final2.file"> | |
<path path="${out.final.file}"/> | |
<mapper> | |
<globmapper from="*.apk" to="*-${manifest.version}.apk" casesensitive="no"/> | |
</mapper> | |
</pathconvert> | |
<echo>Final Package: ${out.final2.file}</echo> | |
<move file="${out.final.file}" tofile="${out.final2.file}" /> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment