Welcome to Jenkins

58
First Step to Jenkins @somkiat

description

Welcome to Jenkins

Transcript of Welcome to Jenkins

Page 1: Welcome to Jenkins

First Step to Jenkins

@somkiat

Page 2: Welcome to Jenkins

Prepare Env

Java

Apache Maven

Git

Github

Page 3: Welcome to Jenkins

Prepare Env

Java

Git

Github.com Account

Config SSH Key

Page 4: Welcome to Jenkins

Install Java

Download from Oracle

Testing

$javac -version

$java -version

Page 5: Welcome to Jenkins

Install Git

Download from http://git-scm.com/

$apt-get install git-core

Testing

$git —version

Page 6: Welcome to Jenkins

Create Account at Github

Goto http://www.github.com

Page 7: Welcome to Jenkins

Config SSH Key

Create SSH Key

$ssh-keygen

Copy your SSH Key from ~/.ssh

id_rsa => private key

id_rsa.pub => public key

Page 8: Welcome to Jenkins

Copy key to Github

Goto account setting => SSH Keys

Page 9: Welcome to Jenkins

Add your public key

Page 10: Welcome to Jenkins

Fork Example Project

Project at https://github.com/up1/demo_jenkin_project

Page 11: Welcome to Jenkins

Fork

Page 12: Welcome to Jenkins

Testing with clone

$git clone [email protected]:<username>/demo_jenkin_project.git

Page 13: Welcome to Jenkins

Setup Jenkins

Download from http://jenkins-ci.org/

Page 14: Welcome to Jenkins

Start Jenkins

$java -jar jenkins.war

Page 15: Welcome to Jenkins

Welcome Jenkins

http://localhost:8080

Page 16: Welcome to Jenkins

Manage Jenkins

Page 17: Welcome to Jenkins

Main Configuration

Page 18: Welcome to Jenkins

Config Jenkins

JDK

Apache Maven

Notification

Git plug-in

Page 19: Welcome to Jenkins

Config JDK

Default => Download from Oracle

Page 20: Welcome to Jenkins

Config JDK

Use JAVA_HOME

Page 21: Welcome to Jenkins

Config Maven

Default => Download from web

Page 22: Welcome to Jenkins

Config Maven

Use MAVEN_HOME

Page 23: Welcome to Jenkins

Notification

Page 24: Welcome to Jenkins

Setup Git

Install Git plug-in

Goto Manage Jenkins

Manage Plug-in

Page 25: Welcome to Jenkins

Git Plug-in

Page 26: Welcome to Jenkins

Installing

Page 27: Welcome to Jenkins

Create First Build Job

New Job/Item

Pull code from GitHub.com

Scheduling to build job

Build process

Report

Page 28: Welcome to Jenkins

Step 1 New Item

Page 29: Welcome to Jenkins

Step 2 Create Job

Page 30: Welcome to Jenkins

Pull code from GithubSet git repository

Page 31: Welcome to Jenkins

Config Build Trigger

Build after project

Build period

Poll SCM

Page 32: Welcome to Jenkins

Poll SCM

minute (0-59)

hour (0-23)

day of month (1-31)

month (1-12)

day of week (0-7)

Page 33: Welcome to Jenkins

Poll SCM

Every minute => * * * * *

Page 34: Welcome to Jenkins

Build process

Build with maven goal

Page 35: Welcome to Jenkins

Build process

clean package

Page 36: Welcome to Jenkins

Create Report

Post Build Action => JUnit Report

Page 37: Welcome to Jenkins

Achieve Artifact

Page 38: Welcome to Jenkins

Try to Build

Page 39: Welcome to Jenkins

See Result

Page 40: Welcome to Jenkins

Test Report

Page 41: Welcome to Jenkins

See Result

Page 42: Welcome to Jenkins

Add JavaDoc ?

How To ?

Page 43: Welcome to Jenkins

Add JavaDoc

Post-build => Publish JavaDoc

Page 44: Welcome to Jenkins

You MUST got ERROR

Try to add javadoc:javadoc

add path of JavaDoc

./target/site/apidocs

And build again !!!

Page 45: Welcome to Jenkins

Result of JavaDoc

Page 46: Welcome to Jenkins

JavaDoc

Page 47: Welcome to Jenkins

Add Cobertura

What is Cobertura ?

Code coverage utility for Java

http://cobertura.github.io/cobertura/

Page 48: Welcome to Jenkins

Add Code CoverageUse Cobertura plug-in

http://cobertura.github.io/cobertura/

Page 49: Welcome to Jenkins

Maven Project

pom.xml

Config plug in to generate cobertura.xml

Page 50: Welcome to Jenkins

pom.xml for Cobertura

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.6</version> <configuration> <formats> <format>xml</format> </formats> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>cobertura</goal> </goals> </execution> </executions></plugin>

Page 51: Welcome to Jenkins

Add goal on Build process

cobertura:cobertura

Page 52: Welcome to Jenkins

Add post-build

Publish Report

Page 53: Welcome to Jenkins

Advanced…

Page 54: Welcome to Jenkins

Build and See Result

Page 55: Welcome to Jenkins

Build and See Result

Page 56: Welcome to Jenkins

Coverage Report

Page 57: Welcome to Jenkins

Report by file

Page 58: Welcome to Jenkins

Welcome to Jenkins