Jenkins Build Jobs


In continuation to my previous blogs Introduction to Jenkins and Jenkins – Manage Security , I will now be talking about creating build jobs with Jenkins.
It is easy and simple to create a new build job in Jenkins. Follow the given steps to get started:
  • From the Jenkins Dashboard, Click on “New Item”
  • Name your project and select project type.

1

  • Click on “Ok” to continue.
Understanding Build Job Types
Jenkins supports different types of build jobs. Some of them are :
  • Freestyle software project
Freestyle build jobs are general-purpose build jobs, which provides a maximum of flexibility. This is the central feature of Jenkins. Jenkins will build your project, combining any SCM with any build system, and this can be even used for something other than software build.
  • Maven project
Build a maven project. Jenkins takes advantage of your POM files and drastically reduces the configuration.
  • External Job
This type of job allows you to record the execution of a process run outside Jenkins, even on a remote machine. This is designed so that you can use Jenkins as a dashboard of your existing automation system.

  • Multiconfiguration job
The “multiconfiguration project” (also referred to as a “matrix project”) lets you run the same build job in many different configurations. This powerful feature can be useful for testing an application in many different environments, with different databases, or even on different build machines.
Configure project
Once you are done creating the project, your next step is to setup configurations which include :
1) Configuring Global Tool Configuration
Here you can set JDK path, git configurations and Gradle/ Ant or Maven installations as per your project requirement.
2) Creating or updating(if already created during project creation) project configuration settings which may include General settings, Source code management, build triggers, Pre-steps, Build, Post Steps, Emailing notification regarding build and post build actions as per your project need.
Reporting on Test results
Once all the test cases are executed during build, one of the essential part is to generate the test results. This can be specified in the “post build action” part.
For maven jobs, you need not to provide any special configuration. All you need to do is to make sure you invoke a goal that will run your test cases. Ex: mvn test(for unit test) or mvn verify(for unit and integration test).
2
For “freestyle build jobs”, you need to do a bit of more configuration work. In addition to ensuring that your build actually runs the tests, you need to tell jenkins additionally to publish the Junit test report. It can be configured in the “Post build actions” section.
  • From Post Build Actions –> Select “Publish Junit test result report”.
  • Apply and save the configurations.
3

NOTE: Jenkins looks for the “Test report XMLs” path from the workspace root for generating the report. Ensure that the given path is correct or use wildcards to look in multiple locations. To know workspace you can run “echo ${WORKSPACE}”.

Manage Nodes

Jenkins handles parallel and distributed builds well. Jenkins runs simultaneously, and, if you are using distributed builds, set up build nodes. A build node is another machine that Jenkins can use to execute its builds.

1. To execute builds on another machine, you need to create a node in jenkins and then you need to tell your project about the node where it has to run.

Follow the given steps to create a node:

Jenkins Dashboard –> Manage Jenkins –> Manage Nodes –> New Node

2. Name your node and Select the appropriate option and Click “OK”.

3. After that you will be able to see your node under the nodes

Provide “Remote root directory” where you want your jenkins projects to be stored on your machine along with the credentials (if required) to connect to that machine.

Once a node is created, it can be used to run the projects which are setup on jenkins. This can be done by selecting “Restrict where the project can run field.” which can be found in the respective project configuration in “General Tab”.

Suppose if the created node has name “194.178.2.59_Node”. Then it could be set as per the image:

4

In my next blog, I shall be elaborating on “Setting Email Configurations” with Jenkins. Stay tuned ! 

References:

  1. Jenkins-The Definitive Guide by John Ferguson Smart

KNOLDUS-advt-sticker

Advertisements
This entry was posted in integration, Performance Testing, testing, Tutorial. Bookmark the permalink.

2 Responses to Jenkins Build Jobs

  1. Pingback: Jenkins – Integrating Email Service | Knoldus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s