If you follow these instructions, I do expect you to have some level of knowledge on:
- how to handle Red Hat Enterprise Linux or any of it’s clones
- when to click
Applyor any related button on a web page
Install Jenkins on RHEL
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
$ sudo yum install jenkins
Note: first check if you have
git and a jdk installed on your system. If you don’t please install them first!
To start Jenkins run
sudo service jenkins start
If you run Jenkins, like in this setup, on some public server, it makes sense to enable security.
To do so, please follow these steps:
- Go into the configuration section of your Jenkins installation
- Enable security by clicking the button
- Define security settings to your needs
Close this step by applying and saving the changes.
- Create the user under which you want to do admin things. Dependend on the type of Access Control selected in the previous step, this might be different for you. For this environment I choose to use Jenkins’ own database, so I had to create the user.
- If indicated by Jenkins, you could run an update on already installed plugins.
- I would always recommend to restart Jenkins after installing/updating new plugins.
Install required plugins
Now it is time to install the plugins, which we need for the planned deployment pipeline and for the deployment to Red Hat OpenShift Online. To do so, go into the plugin section of the configuration of Jenkins.
Find and install the following plugins:
- OpenShift Deployer
- Build Pipeline
- Parameterized Trigger
- Copy Artifact
To be able to clone projects from any git repository, like github, we need to configure the path to the
git executables. Go into the configuration section of Jenkins.
Locate the Git section and apply your relevant setting.
Install and configure ‘maven’
During our build procedure, we will be using Maven to create our deployables. So please go into the configuration of Jenkins and add a Maven environment.
Configure OpenShift Plugin
To be able to deploy artifacts to OpenShift, we have to do some configurations in Jenkins.
First we need to create and upload ssh-keys, as described here:
Then we need to configure the OpenShift server, which we want to deploy to.
Instead of manually uploading the ssh-key, you can also do the same at this point via
To be able to automate code quality checks, we will need to install Sonar. To do so, follow the following steps
$ sudo wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo
$ yum install sonar
If you are OK with using the embedded H2 database, this is all you need to do.
To start the Sonar server run
$ sudo service sonar start
You can log in with the default account “admin” with password “admin”. The first thing you should do is of course change the password on the page under “Administrator” > “My Account”. After that you can disable access from anonymous users in the “Settings” > “Configuration” > “Security” page by selecting True in the “Force user authentication” setting.
Create the steps of the deployment pipeline
Stage 1 – Code Quality Check
We will start with creating a first Jenkins jobs
We will name this step
01 - Code Quality and will make it a `Freestyle` format.
Enter the URL to the github repository
To be able to finalise the git configuration, you have to define your credentials, like shown here
Please replace the URL and password to your values.
Select the build-trigger that you want for your environment. In this case I want the build to be started, when an update is pushed to github.
Define a Maven-Build as the first build step
Then we do the Sonar code quality check. For this you just have to add a Standalone Sonar Analysis
As we want to re-use the created artifacts for our later stages, we do have to tell Jenkins to archive it. This is done as a Post-Build-Action.
Create the first deployment to OpenShift
Start the definition of a new Jenkins job.
We do not want to build the deployment artifacts again, so we need to copy them from the previous step. To do so, please define the following build step.
Then we need to configure the deployment to OpenShift as another Build Action.
Link the first and second stage
As we are establishing a build pipeline, we need to trigger the deployment to OpenShift as an automated follow-up step to the Code-Quality step.
To do so, please go back into the configuration of the Code-Quality step and add the triggering of Stage 2 as a Post Build
Usually if one creates a build pipeline, like we are doing here, one wants to see this pipeline as well. This is where the previously installed Build Pipeline plugin comes into action.
To configure it, go to the start page of Jenkins. I usually do so by clicking
Jenkins in the bread-crumb menu. Once one the startpage, add a new view by clicking the
+ sign, as shown on the image.
Give you Build Pipeline a name.
On the configuration page of the newly created view, select what you want to be shown, etc. The only crutial point is the selection of the initial job, otherview the view wouldn’t know where to start.
When finished, you should see the current state of your pipeline.
This comples the simple version of our build pipeline with Jenkins and Red Hat OpenShift. Feel free to extend to your liking.