My favorites | Sign in
Project Home Wiki Issues Source
Getting going with Jenkins
Updated Apr 8, 2012 by

Adding a projects to Jenkins

Preparing a project for Jenkins


 <project xmlns=""
   <modelVersion>4.0.0</modelVersion>   <groupId>simple-code-patterns</groupId>   <artifactId>java_patterns</artifactId>   <version>0.0.1</version>   <packaging>pom</packaging>   <name>java_patterns</name>   <build>     <sourceDirectory>src</sourceDirectory>     <outputDirectory>build/classes</outputDirectory>   </build>   <properties>     <sonar.language>java</sonar.language>
   </properties>   <ciManagement>     <system>Hudson</system>     <url>http://localhost:8080/job/java_patterns/</url>   </ciManagement> </project>


# Purpose: Manually test the Maven to Sonar interface.

#cd .. # build the code. ant sonar

# Load the data to Sonar mvn -f pom.xml -e -B sonar:sonar -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8

# Clean up after maven run. rm -rf target

# clean up after ant ant clean

Adding a single/simple build to jenkins

  1. create a pom.xml
  2. Goto the Jenkins server home page.
  3. click 'New Job'
    1. fill in name
    2. Select 'Build a free-style software project'
    3. Click Ok, at the bottom.
  4. Fill in description
  5. Select the 'Source Code Management'
  6. set Build Triggers
    • E.g: time trigger: '0 5 ' Builds every day at five in the morning.
  7. Click 'Add build steps'
    • select 'Execute shell' for a std Makefile set-up.
    • cd c_patterns; make sonar
  8. Go to 'Post-build Actions'
    • Sonar:
  9. Click 'Save'


  1. sudo apt-get install jenkins
  2. sudo apt-get install maven2
    • Needed for interfacing with sonar.
  3. go get the plugins.

Creating a project

Integrating with sonar


On Jenkins

  1. Select: Manage Jenkins -> Manage Plugins
  2. Select the 'Available' plugin.
  3. Search for 'Sonar plugin'
  4. Select it
  5. Scroll to the bottom and click 'Install'
  6. Click the 'Restart Jenkins' button.
  7. Select 'Manage Jenkins' -> 'Configure System'
  8. In the sonar section click Add Sonar.
  9. Fill out the fields:
    • Name: SonarServer
    • Database URL: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
      • This can be found under 'sonar.jdbc.url:' in the sonar 'conf/'
    • Database login: sonar
      • sonar.jdbc.username:
    • Database driver: com.mysql.jdbc.Driver
      • under sonar.jdbc.driverClassName:
    • Got to the bottom and click 'Save'
    • For each project
    1. Go to theproject
    2. Select configure
    3. Check of sonar
    4. fill out fields
    5. Click save

On Sonar

  1. download | Build stability
  2. copy it extensions/plugin
  3. restart sonar.
  4. Also remember to login and add the widget to the dashoard
  5. Add ciManager to each projects pom.xml file.

 <ciManagement>   <system>Hudson</system>   <url></url> </ciManagement> 



version control errors

Git problem

FATAL: Could not apply tag jenkins-AgileTest-5



  1. In the browser go to: jenkins -> Manage Jenkins -> Configure System
  2. Scroll down to 'Git plugin'
  3. insert the values
    • e.g: jenkins / jenkins@localhost

build errors


FATAL: Unable to find build script at



  1. Select 'configure' on the project page.
  2. go to 'Build'
  3. Click 'Advanced'
  4. In the 'Build file' field write : 'AgileTest/build.xml'
    • relative path to build.xml from the root of the git project.
    • 'workspace' has nothing to do with Eclipse.
  5. click 'Save'

The 'build.xml' is actually in the root of agile."

 FATAL: Unable to find build script at /var/lib/jenkins/jobs/AgileTest/workspace/build.xml

Plugin issues

Sonar plugin

Sonar plugin doesn't become available

even though it claims to be succesfully installed prior to reboot.

Upgrading to Jenkins ver. 1.424.3 fixed the issue.

Ubuntu: 11.10 Jenkins: Jenkins ver. 1.409.1 Sonar plugin: 1.8

(doesn't work):
  1. download the plugin manually from:
  2. cp ~/Downloads/sonar.hpi /tmp
  3. sudo -s -H -u jenkins
  4. cd /var/lib/jenkins/plugins

Cannot execute mojo: sonar. It requires a project with an existing pom.xml, but the build is not using one

Create a small pom.xml in the root of the project. See:


<project xmlns=""
  <name>The Name of My Project</name>

Sonar integration

source statistics is not shown

Fix: Make sure sourceDirector is the correct relative path(in pom.xml).

I ended up with the path relative to the project I was testing, not the Git structure.

  • Correct: <sourceDirectory>src</sourceDirectory>
  • Wrong: <sourceDirectory>AgileTest/src</sourceDirectory>

Can not execute Sonar

Added a new C project and the build failed.

Fix: change the language from 'C' (upper case C) to 'c' (lower case c).

In the project configuration under 'Sonar' 'Advanced button under the 'Language' field.

org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
Caused by: java.lang.RuntimeException: Quality profile not found for Automatedliving:AgileTestC, language C
Comment by, Apr 19, 2012

Adding support for multiple source directories:

<groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.7</version> <executions>
<id>add-source</id> <phase>generate-sources</phase> <goals>
</goals> <configuration>
<source>Common</source> <source>FileOps?</source> <source>GetData?</source> <source>Statistics</source>

and in <properties>...</> add:


Sign in to add a comment
Powered by Google Project Hosting