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

Configure Jenkins for a Basic Python Project

Install and set up Jenkins following the official document.

Plugins: Install Jenkins Covertura Plugin + GIT Plugin + Jenkins Violations.

Step 1: Create a new Item “py_analysis” and select “Build a free-style software project”

Step 2: Version Control. I put Git here, with repo URL and credential. I added “SSH username with private key” here. The category of credential may vary depending on users’ situation.

Step 3: Add build step – Execute shell


# Delete previously built virtualenv
#if [ -d $PYENV_HOME ]; then
#    rm -rf $PYENV_HOME

# Create virtualenv and install necessary packages
virtualenv $PYENV_HOME
. $PYENV_HOME/bin/activate
pip install --quiet <LIBS I LOVE>
pip install --quiet pylint
pip install --quiet $WORKSPACE/project/  # where your lives
#nosetests --with-xcoverage --with-xunit --cover-package=model --cover-erase
cd $WORKSPACE/project/testPackage 
nosetests --with-xunit --cover-package=model --cover-erase -a '!slow'
pylint -f parseable $WORKSPACE/project/package | tee pylint.out

Step 4: Post-build Actions
Publish Covertura Coverage Report – Put Covertura xml report pattern as “**/coverage.xml”

Publish Unit Test Report – Put Covertura xml report pattern as “**/nosetest.xml”

Step 5: Save and build.