Jenkins for Maven Project with xUnit on CentOS

Step 1: Install dev env, maven, Jenkins

sudo yum groupinstall "Development Tools"

wget -O /etc/yum.repos.d/epel-apache-maven.repo
sudo wget -O /etc/yum.repos.d/epel-apache-maven.repo
sudo yum insatll apache-maven

wget -O /etc/yum.repos.d/jenkins.repo
rpm --import
sudo wget -O /etc/yum.repos.d/jenkins.repo
sudo rpm --import
sudo yum install jenkins

chkconfig jenkins on #start Jenkins when boot
sudo vim /etc/sysconfig/jenkins # set JENKINS_HTTPS_LISTEN_ADDRESS="" 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
Git repo and credentials
Build Triggers
– Poll SCM
-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