Jenkins for Maven Project with xUnit on CentOS

Step 1: Install dev env, maven, Jenkins

sudo yum groupinstall "Development Tools"

wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo yum insatll apache-maven

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins

chkconfig jenkins on #start Jenkins when boot
sudo vim /etc/sysconfig/jenkins # set JENKINS_HTTPS_LISTEN_ADDRESS="0.0.0.0" to listen on all IPs for HTTPS

Step 2: Setup Jenkins
– Visit host:8080
Configure Global Security: Choose Jenkins user DB and create user. Define matrix security rules: grant only “read” to anonymous user. Disable create user.

– Configure Jenkins System: Specify paths to JDK, Maven
Plugins: install Git Plugin, xUnit Plugin

Step 3: Create a new Item, and fill in the followings
Project name
Description
Git repo and credentials
Build Triggers
– Poll SCM
Build
-Root POM: path to pom in the repo
-Goals and options: test install
Post Steps
-Process xUnit test result report: Specity JUnit Pattern as “surefire-reports/*.xml”
-Configure Failed Tests

Step 4: Trigger build from remote


curl http://jenkinshostname:8080/git/notifyCommit?url=gitpath&branches=yourbranch/HEAD

Advertisements