3

In our environment we are building xamarin.android project and would like to pass $(build_number) variable to Jenkins build. Unfortunately Jenkins is building the project as if nothing was passed to the build workflow.

I tried to use XmlPoke which works fine for windows and doesn't work on mac at all.

os: mac os x jenkins & xamarin are the latest stable version

Please suggest.

Mando
  • 11,414
  • 17
  • 86
  • 167
  • Are you asking how to configured a Jenkins parameterized build, or are you asking how to use your android build command line with parameters? As a matter of fact: what IS your android build command line? – Slav Nov 10 '14 at 16:11
  • this one "or are you asking how to use your android build command line with parameters". I'm using XBUILD (mac os x) – Mando Nov 10 '14 at 18:44
  • So, Jenkins aside, how do you usually pass variables to Xamarin? – Slav Dec 08 '14 at 14:17

3 Answers3

2

I found a good solution from http://jonathanpeppers.com/Blog/xamarin-android-builds-in-jenkins

<Target Name="BeforeBuild" Condition=" '$(JENKINS)' == '1' ">
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionCode" Value="$(SVN_REVISION)" />
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionName" Value="2.0.$(SVN_REVISION)" />
</Target>

Use it in your .csproj file and don't forget to set 'JENKINS' as a global environment with a value of 1.

1

There is no default solution/plugin for it if you are building under Mac OS Host. You have to create your own script/tool with input parameters to update xml attributes to a given value. Then use it with shell exec task.

Mando
  • 11,414
  • 17
  • 86
  • 167
0

According to this link, you can access environment build variables in csproj file using $(VAR) notation.

So, predefined Jenkins variables, such as BUILD_NUMBER should be available directly inside your project use $(BUILD_NUMBER), nothing extra required during invocation.

Slav
  • 27,057
  • 11
  • 80
  • 104
  • what does it mean to "use inside you project". Yes, I have that variable but I need to update the manifest/plist with the build number. Basically modify an xml file during build process – Mando Dec 09 '14 at 01:53
  • Your question states: "we are building xamarin.android project and would like **to pass $(build_number) variable to Jenkins build**". I further asked you in comments what you wanted, and you confirmed "how to use your **android build command line with parameters**". I've answered how to pass/use variables to your android build. Nowhere did you ask about updating xml – Slav Dec 10 '14 at 17:02
  • 2
    I didn't understood the comment. The question is in subject "What is the right way to update android manifest with xbuild and Jenkins" – Mando Dec 12 '14 at 20:36