Part -2: Setting up Jenkins server

Shivaraj Patil
3 min readNov 4, 2017

--

Hey folks this is the part 2 of the series, if you haven’t read Part-1 check it out

Let’s see how we can setup Jenkins server up

Goto Jenkins -> Manage Jenkins -> Configure System

  • Click on Environment variable check box and setup ANDROID_HOME
Environment variables
  • Then scroll down to Extended E-mail Notification to setup email notification

Click Apply & Save.You can find detailed plugin installation for Email here & more here

1. Create New Job by clicking Jenkins -> New Item

Create new jenkins job

Enter project name and select Freestyle project then at the bottom hit Ok

2. Enter project description, under Source COde management select git and paste your git repository link.

For public repository no need to specify credentials but for private repository you should create credentials.

Check how to setup private repository: https://gist.github.com/shivarajp/f8235bcfe03b31da1682a72e8a2b5f29.js

3. Under Build click on Add build step ->Execute shell (Windows: Execute Windows Batch command)& add gradlew command ./gradlew assembleDebug

Note: You need to add execute permission to your gradlew file by executing chmod +x gradlew command.

Add one more step and add the spoon command

java -jar spoon-runner-1.6.4-jar-with-dependencies.jar — — apk app/build/outputs/apk/plaid-debug.apk — — test-apk app/build/outputs/apk/plaid-debug-androidTest.apk

make sure that your apk path is correct. (Later we will see where to put spoon jar file)

add build step

4. Their is one more command we need to add to generate HTML report that we will attach to out mail body.

php EmailTestResults.php

Above command will create HTMLEmailResult.html file by consuming the result.json file from /spoon-report/, I wrote a php script to do that. You can find the script here. Download this script & keep it in your project’s root folder so that we keep everything at one place and access it easily, but it’s not mandatory to keep it in project folder.0

php command

5. Under Post-build Actions Add post build action -> Editable Email Notification

post build step email setup

To email we will attach Build log & you can also attach other files as well, in email body we will add html report we generate (I will explain this in a while)

This is how we add html to email body & select Content type as HTML/Text ${FILE,path=”HTMLEmailResult.html”}

That’ it we have successfully setup our jenkins server, now we will spoon.

Part 3: Setting up Spoon & Espresso

--

--

Shivaraj Patil

Entrepreneur, Android enthusiast, passionate Android Developer worked @Triveous skyroapp.com