Possibility usage of Jenkins and its plugin

1. Jenkins Master-Slave model

2. Send notification/report by MAIL (Email-ext plugin)

3. Create JIRA ticket to assign task (JIRA plugin)

4. Build source code

5. Execute STATIC code analysis (Coverirty, SonarQube)

6. Execute SECURITY analysis ()

7. Execute UNIT test (JUNIT, EMMA)

8. Execute INTERGRATION test (Automation UI)

9. Execute JIRA query and report (REST API, JIRA PLUGIN)

10. Pipeline

 

1. Jenkins Master-Slave model
Master connect to Slave by SSH.

Two way to let Slave start build code.
– Slave pull code from SCM. Then Slave build.

– Master pull code from SCM and copy to Slave. Then Slave build.
https://wiki.jenkins-ci.org/display/JENKINS/Copy+To+Slave+Plugin

2. Send notification/report by MAIL (Email-ext plugin)
http://www.nailedtothex.org/roller/kyle/entry/articles-jenkins-email

3. Create JIRA ticket to assign task
JIRA plugin, Jira Issue Updater, JiraTestResultReporter plugins
http://www.agiletrailblazers.com/blog/how-to-make-your-scrum-master-happy-using-jira-integrations
(integration JIRA-GITHUB-JENKINS in a develoment loop)

4. Build source code
5. Execute STATIC code analysis (Coverirty, SonarQube)
http://macoscope.com/blog/using-sonarqube-with-jenkins-continuous-integration-and-github-to-improve-code-review/

https://lasithapetthawadu.wordpress.com/2014/05/03/configure-jenkins-with-sonarqube-for-static-code-analysis-and-integration/
Jenkins perform automated builds and would execute unit tests.
During this process it would run a sonarqube runner which ultimately integrates the static analysis results to the SonarQube dashboard.
Sonar is better than Coverity at following:
– Coud add/change rule, norm in Quality Gate
– Expose WebAPI so that external could access its database
– Bug/Vulnerability/CodeSmell/TechnicalDept
6. Execute SECURITY analysis (SSC)
7. Execute UNIT test
(Junit on target device, coverage analysis report by EMMA)

8. Execute INTERGRATION test (Automation UI)
9. Execute JIRA query and report
Via REST API???
10. Pipeline

Build Anddroid app from GIT/Gerrit by Jenkins

Build Anddroid app from GIT/Gerrit by Jenkins

(assump to use ANT in Jenkins to compile)

Jenkins – Setup a simple Ant build project
PREPARE ANDROID CODE ON GIT
1. Create Android app in Eclipse in local

2. Export build.xml from Eclipse
By Eclipse: Export/Ant build files
By terminal: android update project -p ./newtestapp
(if do not have build.xml, Jenkins will not be able to compile because Ant need build.xml)

3. Commit Android app source to Gerrit
(commit all except ./bin and ./gen folder)

4. Select CodeReview+2 to merge commited code to Git

CONFIG JENKINS TO USE ANT
5. Setup JDK path
Manage Jenkins -> Global Tool Configuration
(specify existed JDK or let Jenkins download new one)

6. Setup ANDT path
Manage Jenkins -> Global Tool Configuration
(I let Jenkins download new ANT so that user access right is OK for “jenkins” user)

BUILD JOB
7. Create build JOB

8. Setting build JOB
Source Code Management: GIT
– Repository URL: http://127.0.0.1:8087/gerritdemo.git
– Credentials: account which link to account which could access GIT (already setting previously)
– Branch Specifier: */master

Build trigger: Gerrit event

Gerrit Trigger
– Server: gerritserver (Name of gerrit server)
– Gerrit project: gerritdemo (name of a project on gerrit server)
– Branch: master

Build step: select Invoke ANT
– ANT version: Select ANT version
– ANT target: let empty or debug (any target existed in build.xml file)

Post build:
– Files to archive: **/*.apk
(if you dont setting, jenkins only compile source, not created APK)

9. Execute build JOB
– Commit a new change from GIT -> GERRIT then JENKINS will trigger build JOB immediately.
(even you haven’t +2 in Gerrit)

– OR you could actively exectute build JOB in Jenkins.
(select “Build now” or “Re-trigger”

NOTE:
– You could face error if there is not enough: build.xml, project.properties, etc…
– You could face error if “build file” parameter of ANT in Jenkins is different than your actual build.xml path in GIT.
In that case, modified it in JOB configure -> Build -> Invoke Ant -> Advanced -> Build file
– After build successfully, you could install your output APK to Emulator to check.

Setup Git, Gerrit, Jenkins on Ubuntu 14.04 (CI)

Install Git, Gerrit, Jenkins on Ubuntu 14.04
(for detai refer: https://www.linkedin.com/pulse/code-review-continuous-integration-setup-gerrit-jenkins-dash)

Main steps

GIT
1. Install Java7
2. Install Git

GERRIT
3. Download Gerrit From official site
4. Install Gerrit
(should change  listenUrl port to 8087 of gerrit by edit gerrit.config)
5. Sign in Gerrit using OpenID (eg Yahoo mail).
(if want to use your own register mail, please install apache and change gerrit config to HTTP)
http://your_ip_address>:8087

6. Change user name, email address
7. Input SSH key to Gerrit (so that git could connect to gerrit)
8. Generete HTTP password (so that Jenkins could connect to gerrit)
9. Create new project
10. From terminal, use Git to clone project to local
11. Edit, commit changes (optional)

JENKINS
12. Install Jenkins.
13. Access Jenkins
http://your_ip_address>:8080
14. Install plugin: Gerrit trigger + Git parameter plugin
15. Config Jenkins for gerrit on Gerrit trigger
(please genereate new SSH key under “jenkins” user and use here in setting page. If not you will face error)
cd  /var/lib/jenkins
sudo su jenkins
ssh-keygen -t rsa
(NOTE: pls use EMPTY passpharse)
16. Test connection (SSH & REST)
17. Create job (which will be trigger if there is any change on Gerrit)
18. Use git to commit new change
19. On Gerrit, review and merge the change.
20. Check the job was executed on Jenkins