We start by accessing the the web-based user interface of Jenkins that is available at http://localhost:8080/ and clicking on the New Job link in the upper left corner. This will start Jenkins' wizard to create a new job. On its first page, the wizard asks us for a name for the project and the type of project we want to build (see Figure 3-1). We choose free-style software project as this allows us to configure a job that can combine any version control system with any build system.
The second (and final) page of the wizard we configure the details of the job including what to build as well as how and when to build it.
In the Source Code Management section (see Figure 3-2) of the form we configure the version control system we want to use. We are using Git for our example and fill in the repository's URL (git://github.com/thePHPcc/bankaccount.git) as well as the name of the branch we want to integrate (master).
In the Build Triggers section (see Figure 3-3) of the form we configure when Jenkins should build our job. There are three possible triggers for building a job:
A job can be configured to be built when changes to the source code are detected. The version control system will be periodically polled for the required information.
A job can be configured to be built at specific times or intervals, for instance every night or every two hours.
A job can be configured to depend on another job. A new build is triggered when a build of that other job finishes.
We configure our job to poll the Git repository every minute. As
Jenkins uses the syntax (with minor differences) of cron, the time-based
scheduler in Unix-like operating systems, to specify build intervals, we
fill in * * * * *
in the
Schedule field.
Now that we have configured what to build and when build it, the next step is to configure how to build it. Since we are using Apache Ant for building our project this is really easy, as can be seen in Figure 3-4.
The only things left to do are configuring the two reports, test results and code coverage, that we want Jenkins to publish. For this we simply need to configure the locations of the respective build artifacts ( build/logs/junit.xml, build/logs/clover.xml, and build/coverage) as can be seen in Figure 3-5 and Figure 3-6.
Figure 3-7 through Figure 3-11 show how Jenkins reports the information collected during the build.