Difference between revisions of "CI/Jenkins"

From OpenMBD
< CI
Jump to: navigation, search
Line 2: Line 2:
  
  
<i>Put Jenkins logo here</i>
+
[[File:JenkinsLogo.png|400px]]
  
 
== Introduction to Jenkins ==
 
== Introduction to Jenkins ==
  
<i>Short explanation of what Jenkins is and why we chose Jenkins...</i>
+
Jenkins is a Continuous Integration (CI) server written in Java. With CI it is possible to run the tests on a server computer automaticcally everytime when someone commits new code into the repository. 
 +
Because of this, there is always a fast feedback of the tests. This is important, because by this way it is simple to see when the build exactly is broken.
 +
There are hunderds of plug-ins that can be installed to set up the build to your wish.
 +
 
 +
We choose for Jenkins because it is simple to use and the variety of the configuration that is possible with Jenkins.
  
  
Line 12: Line 16:
 
== Installation ==
 
== Installation ==
  
<i>Installation Procedure</i>
+
 
 +
In order to install Jenkins, first the executable will need to be downloaded from the site of [https://jenkins.io/index.html| Jenkins]
 +
 
 +
[[File:Jenkins_homepage.png|400px]]
 +
 
 +
Press the download button. A pop-up menu will appear. From the menu select LTS Release (2.73.1) and click on the arrow, select Windows.
 +
 
 +
[[File:LTSRelease.png|400px]]
 +
 
 +
Then unzip the file that where downloaded and then click the executable.
 +
The installation process is going to start. Then follow the installation wizard. Choose the path where you want to install Jenkins. After the installation is over, open the webbrowser and type localhost:8080. It will direct to page as shown on the picture below.
 +
 
 +
[[File:GettingStartedJenkins.png|400px]]
 +
 
 +
Here will be asked to enter the password located in the C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword (this is an example).
 +
 
 +
Once finded the password, copy and paste it under Administrator password. Then press continue. After this press install suggested plugins.
 +
 
 +
[[File:suggestedplugins.png|400px]]
 +
 
 +
After the suggested plugins are installed a window will appear where the username, the password, full name, and email address must be set. After all this information was filled in click Save and finish. In the next window that will appear press Start using Jenkins.
 +
After this the Jenkins Dashboard will appear and will be similar with the picture below.
 +
 
 +
[[File:Jenkins.png|400px]]
  
  
Line 18: Line 45:
 
== Configuration ==
 
== Configuration ==
  
<i>Configuration Procedure</i>
+
 
 +
After this, Manage Jenkins needs to be clicked. A menu will show up and is going to look like the picture below.
 +
 
 +
[[File:ManageJenkins.png|400px]]
 +
 
 +
From the list the button Manage Plugins needs to be selected. The following plugins will need to be installed:
 +
 
 +
* Locale Plugin;
 +
* Multijob Plugin;
 +
* Shared Workspace;
 +
* TestComplete support plug-in;
 +
* SonarQube Scanner support for Jenkins.
 +
In order to install the plugins from the menu (see picture below) the button Available needs to be selected.
 +
 
 +
[[File:availablejenkins.png|400px]]
 +
 
 +
After Available was selected, in the search box it needs to be typed the name of the plugin that it is desired by the user to be install. In this case for example the MultijobPlugin. After the name of the plugin is typed the menu will look like the picture below.
 +
 
 +
[[File:exampleplugin.png|400px]]
 +
 
 +
The box needs to be clicked and then ‘Install without restart’ needs to be pressed.
 +
Then there will appear another menu for example like the picture below.
 +
 
 +
[[File:plugins.png|400px]]
 +
 
 +
The option restart “Jenkins when…” will need to be selected. Then the same procedure will need to be repeated for all the plugins listed in the list above. In case it doesn’t restart automatically a refresh of the page is necessary.
 +
 
 +
 
 +
After the plugins are installed the following programs will need to be installed on the PC:
 +
 
 +
* Apache Ant 1.9.7
 +
* TestExecute 12 
 +
* SonarQube 5.6.6
 +
* SonarQube Scanner 3.0.3.778
 +
 
 +
 
 +
How to install Apache Ant 1.9.7?
 +
 
 +
In order to install Apache-ant-1.9.7 the program needs to be downloaded from the following [http://webscripts.softpedia.com/Apache-Ant/download/| site].
 +
 
 +
On the page, click on the External Mirror (source) and the download will start.
 +
 
 +
The following [https://ant.apache.org/manual/install.html| link] will explain how Apache Ant can be installed.
 +
 
 +
How to install SonarQube LTS (5.6.6) and SonarQube Scanner (3.0.3.778)?
 +
 
 +
SonarQube can be downloaded [https://www.sonarqube.org/downloads/| here].
 +
 
 +
SonarQube Scanner can be downloaded from the [https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner| following link].
 +
 
 +
By clicking on Windows 64 bit as shown on the picture below, the download wil start.
 +
 
 +
[[File:scanner.png|400px]]
 +
 
 +
The following steps must be followed to install SonarQube and SonarQube Scanner:
 +
 
 +
For SonarQube:
 +
 
 +
In Command Prompt go to the map where SonarQube is installed and start the service, for example:
 +
 
 +
C:\Program Files\SonarQube\sonarqube-5.6.6\bin\windows-x86-64>StartSonar.bat
 +
 
 +
If the service is up, SonarQube is installed properly.
 +
 
 +
[[File:cmdsq.png|400px]]
 +
 
 +
This can be checked by the following link: [http://localhost:9000/| SonarQube].
 +
 
 +
On the picture below, on the left side of the screen it shows that the SonarQube server is successfully started.
 +
 
 +
[[File:localhost9000.png|400px]]
 +
 
 +
To change the default port, under the header "WEB SERVER" in the file sonar.properties in the map from SonarQube, the # must be removed and now the sonar.web.port can be changed, for example to 5900.
 +
 
 +
[[File:sonar_web_port.jpg|400px]]
 +
 
 +
For SonarQube Scanner:
 +
 
 +
The following link can be used to install SonarQube Scanner: [https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner| SonarQube Scanner].
 +
These settings must be filled in the project settings in Jenkins (see "Execute SonarQube Scanner").
 +
 
 +
==Configure Jenkins==
 +
 
 +
After Apache Ant, SonarQube and SonarQube Scanner are installed, the next step is to further configure Jenkins.
 +
 
 +
Now ANT, JDK and Sonarqube need to be installed in Jenkins. In order to do this:
 +
 
 +
First the button "Manage Jenkins" in the Jenkins homepage must be pressed, then "Global Tool Configuration" must be clicked. Once the button "Global Tool Configuration" was clicked it will appear a menu that will look like the picture below.
 +
 
 +
[[File:Globaltoolconfigjenkins.png|400px]]
 +
 
 +
The button JDK installations needs to be clicked. Then there will appear a menu that will look like the picture below.
 +
 
 +
[[File:JenkinsJDK.png|400px]]
 +
 
 +
In the "Name" cassette, the name of the JDK must be specified , an example can be seen in the picture above. Then in the cassette of "JAVA_HOME" must be specified the destination of the JDK.
 +
 
 +
In order to install SonarQube Scanner the button SonarQube Scanner installations must be pressed. After the button is pressed there is going to appear a screen something similar with the picture below.
 +
 
 +
[[File:JenkinsSonarQubeScanner.png|400px]]
 +
 
 +
The same procedure like in the case of the installation of the JDK must be applied for SonarQube Scanner. In the "Name" box must be typed the name of the SonarQube Scanner. In the "SONAR_RUNNER_HOME" must be typed the specified path of the SonarQube Scanner. An example can be seen in the above picture.
 +
 
 +
In order to install ANT the same procedure like in the case of JDK and SonarQube Scanner must be applied.
 +
 
 +
[[File:JenkinsANT.png|400px]]
 +
 
 +
An example of how ANT needs to be installed in Jenkins can be seen in the picture above.
 +
 
 +
After the programs are installed the next step is to Configure Jenkins. The "Configure System" menu can be accessed using the following steps: Click "Manage Jenkins", then click "Configure system". The menu that will appear will look like the picture below.
 +
 
 +
 
 +
[[File:JenkinsConifgure.png|400px]]
 +
 
 +
Then the next step SonarQube server needs to be configured. In order to do this, where "SonarQube servers" is written, the button add SonarQube needs to be clicked. In the "Name" cassette the name of the SonarQube token needs to be filled. After the name was filled in, the "Server URL" of the SonarQube server must be specified. An example can be seen in the picture below.
 +
 
 +
[[File:JenkinsSonarQubeServers.png|400px]]
 +
 
 +
To fill in the "Server authentication token", the token must be made in the SonarQube server. To log in the first time in the SonarQube server, for "Login" type admin and for "password" type also admin, as show in the picture below.
 +
 
 +
[[File:SonarQubeLogin.png|400px]]
 +
 
 +
Now the password can be changed and the token can be made, by clicking on the log in name in the upper right corner (see picture below) and click on "My account".
 +
 
 +
[[File:SonarQubePassword.png|400px]]
 +
 
 +
Then go to "Security" and now the password can be changed (see picture above). After that, the token can be made by typing a name in block "Enter Token Name" and then click on Generate. Then there will be a code that must be copied and pasted in "Server authentication token" in Jenkins, in the configuration of SonarQube server. An example of the SonarQube token (with the code) can be seen in the picture below.
 +
 
 +
[[File:SonarQubeToken.png|400px]]
 +
 
 +
Then te location of jenkins must be specified, an example is shown below.
 +
 
 +
[[File:JenkinsUrl.png|400px]]
 +
 
 +
The next step is to set up the Workspace Sharing. The "Name" can be anyone the user desires. For "Repository URL" the repository must be filled in. An example can be seen in the picture below.
 +
 
 +
[[File:JenkinsWorkspace.png|400px]]
 +
 
 +
The last thing that it needs to be set is the E-mail Notification.
 +
 
 +
Example in case the user has google mail:
 +
 
 +
SMTP server: smtp.gmail.com
 +
 
 +
Default user e-mail suffix: @gmail.com
 +
 
 +
Then the Use SMTP Authentification needs to be selected. Then the user name and password of the google account need to be provided, after this Use SSL needs to be clicked. Then the SMTP port is 465. This is all the information that needs to be filled in order to configure the E-mail plugin.
 +
 
 +
After everything was set the user needs to click save.
 +
 
 +
 
 +
==Configure a job in Jenkins==
 +
 
 +
In order to cofigure a job the following steps must be followed. In the frontpage of jenkins new item must be selected to create a new job.
 +
 
 +
[[File:JenkinsNewItem.png|400px]]
 +
 
 +
Then there wile be a field to type in the name of a job. Here you can also chose the sort of project, HANtune uses Freestyle project.
 +
 
 +
[[File:JenkinsNewProject.png|400px]]
 +
 
 +
Now the project can be configured by clicking on configure.
 +
 
 +
[[File:JenkinsConifgureProject.png|400px]]
 +
 
 +
In "Source Code Management" click on "Subversion" and now add the "Repository URL". Then the credentials can be added by clicking on "add". After that the "Local module directory" can be filled in as desired. An example of the configuration of the "Subversion" can seen in the picture below.
 +
 
 +
[[File:JenkinsSubversion.png|400px]]
 +
 
 +
After that, in "BuildTriggers" Jenkins can be set to build the project whenever desired. In the picture below there is an example of a periodical build. If the schedule is not onderstood, click on the question mark.
 +
 
 +
[[File:JenkinsBuildTriggers.png|400px]]
 +
 
 +
In "Build Environment" click on "With Ant" and set the cassette "Ant Version" to the version that is installed on the PC. An example of this is shown on the picture below.
 +
 
 +
[[File:JenkinsBuildEnvironment.png|400px]]
 +
 
 +
The next step is to set up the Build. In "Build", click on "Add build step" and choose "Execute SonarQube Scanner". Then in the cassette "JDK", type in the verion of the JDK that is installed on the PC. In the cassette "Analysis properties", the following hashes must be removed to execute SonarQube Scanner:
 +
 
 +
* sonar.sources
 +
* sonar.tests
 +
* sonar.java.binaries
 +
* sonar.java.libraries
 +
 
 +
In the picture below shows an example of the path's that are filled in.
 +
 
 +
[[File:JenkinsExecuteSonarQubeScanner.png|400px]]
 +
 
 +
After that the next build step is added. Like how "Execute SonarQube Scanner" is added, is "Invoke Ant" also be added. So click on "Add build step" and choose "Invoke Ant". In the cassette "Ant Version" choose "Default". In the cassette type in build. An example of this is shown on the picture below.
 +
 
 +
[[File:JenkinsInvokeAnt.png|400px]]
 +
 
 +
The same step is repeated for the build step "TestComplete Test". Click on "Add build step" and choose "TestComplete Test". In the cassette "Project suite file", type the path of the project suite of TestComplete test. Then you can choose the level of the building step, for example choose "Entire suite". The picture below shows the build step "TestComplete Test".
 +
 
 +
[[File:JenkinsTestCompleteTest.png|400px]]
 +
 
 +
After that the settings of the "TestComplete Test" must be configured. Click on "Advanced" under the "TestComplete Test". In the cassette "Test Runner" chose "Any". In the cassette "version" chose "Latest". In the cassette "Action on warnings chose "None". And in the cassette "Ation on errors" chose "Mark as UNSTABLE".
 +
After that chose "Run interactive user session (TestComplete/TestExecute 10.6 or later is required)". Set up the next cassettes: "User" and "Password" of the PC. In the picture below is shown the settings of the build step "TestComplete Test".
 +
 
 +
[[File:JenkinsBuildSettings.png|400px]]

Revision as of 10:42, 31 October 2017


Back to Home


JenkinsLogo.png

Introduction to Jenkins

Jenkins is a Continuous Integration (CI) server written in Java. With CI it is possible to run the tests on a server computer automaticcally everytime when someone commits new code into the repository. Because of this, there is always a fast feedback of the tests. This is important, because by this way it is simple to see when the build exactly is broken. There are hunderds of plug-ins that can be installed to set up the build to your wish.

We choose for Jenkins because it is simple to use and the variety of the configuration that is possible with Jenkins.


Installation

In order to install Jenkins, first the executable will need to be downloaded from the site of Jenkins

Jenkins homepage.png

Press the download button. A pop-up menu will appear. From the menu select LTS Release (2.73.1) and click on the arrow, select Windows.

LTSRelease.png

Then unzip the file that where downloaded and then click the executable. The installation process is going to start. Then follow the installation wizard. Choose the path where you want to install Jenkins. After the installation is over, open the webbrowser and type localhost:8080. It will direct to page as shown on the picture below.

GettingStartedJenkins.png

Here will be asked to enter the password located in the C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword (this is an example).

Once finded the password, copy and paste it under Administrator password. Then press continue. After this press install suggested plugins.

Suggestedplugins.png

After the suggested plugins are installed a window will appear where the username, the password, full name, and email address must be set. After all this information was filled in click Save and finish. In the next window that will appear press Start using Jenkins. After this the Jenkins Dashboard will appear and will be similar with the picture below.

Jenkins.png


Configuration

After this, Manage Jenkins needs to be clicked. A menu will show up and is going to look like the picture below.

ManageJenkins.png

From the list the button Manage Plugins needs to be selected. The following plugins will need to be installed:

  • Locale Plugin;
  • Multijob Plugin;
  • Shared Workspace;
  • TestComplete support plug-in;
  • SonarQube Scanner support for Jenkins.

In order to install the plugins from the menu (see picture below) the button Available needs to be selected.

Availablejenkins.png

After Available was selected, in the search box it needs to be typed the name of the plugin that it is desired by the user to be install. In this case for example the MultijobPlugin. After the name of the plugin is typed the menu will look like the picture below.

Exampleplugin.png

The box needs to be clicked and then ‘Install without restart’ needs to be pressed. Then there will appear another menu for example like the picture below.

Plugins.png

The option restart “Jenkins when…” will need to be selected. Then the same procedure will need to be repeated for all the plugins listed in the list above. In case it doesn’t restart automatically a refresh of the page is necessary.


After the plugins are installed the following programs will need to be installed on the PC:

  • Apache Ant 1.9.7
  • TestExecute 12
  • SonarQube 5.6.6
  • SonarQube Scanner 3.0.3.778


How to install Apache Ant 1.9.7?

In order to install Apache-ant-1.9.7 the program needs to be downloaded from the following site.

On the page, click on the External Mirror (source) and the download will start.

The following link will explain how Apache Ant can be installed.

How to install SonarQube LTS (5.6.6) and SonarQube Scanner (3.0.3.778)?

SonarQube can be downloaded here.

SonarQube Scanner can be downloaded from the following link.

By clicking on Windows 64 bit as shown on the picture below, the download wil start.

Scanner.png

The following steps must be followed to install SonarQube and SonarQube Scanner:

For SonarQube:

In Command Prompt go to the map where SonarQube is installed and start the service, for example:

C:\Program Files\SonarQube\sonarqube-5.6.6\bin\windows-x86-64>StartSonar.bat

If the service is up, SonarQube is installed properly.

Cmdsq.png

This can be checked by the following link: SonarQube.

On the picture below, on the left side of the screen it shows that the SonarQube server is successfully started.

Localhost9000.png

To change the default port, under the header "WEB SERVER" in the file sonar.properties in the map from SonarQube, the # must be removed and now the sonar.web.port can be changed, for example to 5900.

Sonar web port.jpg

For SonarQube Scanner:

The following link can be used to install SonarQube Scanner: SonarQube Scanner. These settings must be filled in the project settings in Jenkins (see "Execute SonarQube Scanner").

Configure Jenkins

After Apache Ant, SonarQube and SonarQube Scanner are installed, the next step is to further configure Jenkins.

Now ANT, JDK and Sonarqube need to be installed in Jenkins. In order to do this:

First the button "Manage Jenkins" in the Jenkins homepage must be pressed, then "Global Tool Configuration" must be clicked. Once the button "Global Tool Configuration" was clicked it will appear a menu that will look like the picture below.

Globaltoolconfigjenkins.png

The button JDK installations needs to be clicked. Then there will appear a menu that will look like the picture below.

JenkinsJDK.png

In the "Name" cassette, the name of the JDK must be specified , an example can be seen in the picture above. Then in the cassette of "JAVA_HOME" must be specified the destination of the JDK.

In order to install SonarQube Scanner the button SonarQube Scanner installations must be pressed. After the button is pressed there is going to appear a screen something similar with the picture below.

JenkinsSonarQubeScanner.png

The same procedure like in the case of the installation of the JDK must be applied for SonarQube Scanner. In the "Name" box must be typed the name of the SonarQube Scanner. In the "SONAR_RUNNER_HOME" must be typed the specified path of the SonarQube Scanner. An example can be seen in the above picture.

In order to install ANT the same procedure like in the case of JDK and SonarQube Scanner must be applied.

JenkinsANT.png

An example of how ANT needs to be installed in Jenkins can be seen in the picture above.

After the programs are installed the next step is to Configure Jenkins. The "Configure System" menu can be accessed using the following steps: Click "Manage Jenkins", then click "Configure system". The menu that will appear will look like the picture below.


JenkinsConifgure.png

Then the next step SonarQube server needs to be configured. In order to do this, where "SonarQube servers" is written, the button add SonarQube needs to be clicked. In the "Name" cassette the name of the SonarQube token needs to be filled. After the name was filled in, the "Server URL" of the SonarQube server must be specified. An example can be seen in the picture below.

JenkinsSonarQubeServers.png

To fill in the "Server authentication token", the token must be made in the SonarQube server. To log in the first time in the SonarQube server, for "Login" type admin and for "password" type also admin, as show in the picture below.

SonarQubeLogin.png

Now the password can be changed and the token can be made, by clicking on the log in name in the upper right corner (see picture below) and click on "My account".

SonarQubePassword.png

Then go to "Security" and now the password can be changed (see picture above). After that, the token can be made by typing a name in block "Enter Token Name" and then click on Generate. Then there will be a code that must be copied and pasted in "Server authentication token" in Jenkins, in the configuration of SonarQube server. An example of the SonarQube token (with the code) can be seen in the picture below.

SonarQubeToken.png

Then te location of jenkins must be specified, an example is shown below.

JenkinsUrl.png

The next step is to set up the Workspace Sharing. The "Name" can be anyone the user desires. For "Repository URL" the repository must be filled in. An example can be seen in the picture below.

JenkinsWorkspace.png

The last thing that it needs to be set is the E-mail Notification.

Example in case the user has google mail:

SMTP server: smtp.gmail.com

Default user e-mail suffix: @gmail.com

Then the Use SMTP Authentification needs to be selected. Then the user name and password of the google account need to be provided, after this Use SSL needs to be clicked. Then the SMTP port is 465. This is all the information that needs to be filled in order to configure the E-mail plugin.

After everything was set the user needs to click save.


Configure a job in Jenkins

In order to cofigure a job the following steps must be followed. In the frontpage of jenkins new item must be selected to create a new job.

JenkinsNewItem.png

Then there wile be a field to type in the name of a job. Here you can also chose the sort of project, HANtune uses Freestyle project.

JenkinsNewProject.png

Now the project can be configured by clicking on configure.

400px

In "Source Code Management" click on "Subversion" and now add the "Repository URL". Then the credentials can be added by clicking on "add". After that the "Local module directory" can be filled in as desired. An example of the configuration of the "Subversion" can seen in the picture below.

JenkinsSubversion.png

After that, in "BuildTriggers" Jenkins can be set to build the project whenever desired. In the picture below there is an example of a periodical build. If the schedule is not onderstood, click on the question mark.

JenkinsBuildTriggers.png

In "Build Environment" click on "With Ant" and set the cassette "Ant Version" to the version that is installed on the PC. An example of this is shown on the picture below.

JenkinsBuildEnvironment.png

The next step is to set up the Build. In "Build", click on "Add build step" and choose "Execute SonarQube Scanner". Then in the cassette "JDK", type in the verion of the JDK that is installed on the PC. In the cassette "Analysis properties", the following hashes must be removed to execute SonarQube Scanner:

  • sonar.sources
  • sonar.tests
  • sonar.java.binaries
  • sonar.java.libraries

In the picture below shows an example of the path's that are filled in.

JenkinsExecuteSonarQubeScanner.png

After that the next build step is added. Like how "Execute SonarQube Scanner" is added, is "Invoke Ant" also be added. So click on "Add build step" and choose "Invoke Ant". In the cassette "Ant Version" choose "Default". In the cassette type in build. An example of this is shown on the picture below.

JenkinsInvokeAnt.png

The same step is repeated for the build step "TestComplete Test". Click on "Add build step" and choose "TestComplete Test". In the cassette "Project suite file", type the path of the project suite of TestComplete test. Then you can choose the level of the building step, for example choose "Entire suite". The picture below shows the build step "TestComplete Test".

JenkinsTestCompleteTest.png

After that the settings of the "TestComplete Test" must be configured. Click on "Advanced" under the "TestComplete Test". In the cassette "Test Runner" chose "Any". In the cassette "version" chose "Latest". In the cassette "Action on warnings chose "None". And in the cassette "Ation on errors" chose "Mark as UNSTABLE". After that chose "Run interactive user session (TestComplete/TestExecute 10.6 or later is required)". Set up the next cassettes: "User" and "Password" of the PC. In the picture below is shown the settings of the build step "TestComplete Test".

JenkinsBuildSettings.png