Setting up Jenkins for a Gauge project

Continuous Integration using Jenkins for Gauge Projects

Osanda Deshan Nimalarathna
Test Automation Master
4 min readNov 26, 2018

--

What is Continuous Integration?

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

What is Jenkins?

Jenkins is a Continuous Integration server.

Basically continuous integration is the practice of running your tests on a non-developer machine automatically every time someone pushes new code into the source repository.

This has the tremendous advantage of always knowing if all tests work and getting fast feedback. The fast feedback is important so you always know right after you broke the build (introduced changes that made either the compile/build cycle or the tests fail) what you did that failed and how to revert it.

Download and Setup Jenkins

  1. Go to the Jenkins website and download Jenkins.
    Latest stable Jenkins war file: http://mirrors.jenkins.io/war-stable/latest/jenkins.war
    Or
    Platform specific installations: https://jenkins.io/download/
  2. If you download the war file, Open the command prompt and navigate to the war file contain directory.
    Then execute this command to start the Jenkins server.
    java –jar jenkins.war
    If you download the installer, Just double click it and go through the wizard.
  3. By default, Jenkins server will open in port 8080.
  4. Navigate to this URL.
    http://localhost:8080
  5. And it will open the Jenkins Setting up Wizard.
  6. Initially Jenkins creates a password which will be saved inside the Jenkins directory.
    <Jenkins_Dir>\secrets\initialAdminPassword
    Ex:-
    Windows: C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword
    MacOS: /Users/Shared/Jenkins/Home/secrets/initialAdminPassword
Unlock Jenkins

7. Open this initialAdminPassword file using NotePad.

8. Copy the secret key and paste it as the Initial Admin Password in the Jenkins setup wizard.

9. After that, you can configure your own username and password for Jenkins.

Creating the Admin User

10. Then login to the Jenkins dashboard.

Jenkins Configurations

Configure the JDK

1. Go to Manage Jenkins → Global Tool Configuration → JDK and click on Add JDK button.

Global Tool Configuration

2. Un check Install automatically check box.

3. Provide the Name as JAVA_HOME, and the JDK installed directory as the JAVA_HOME.

Setting up JDK

4. Click on Save button.

Setting up a new Jenkins job

  1. Click on New Item button in Jenkins Dashboard.
Setting up a new Jenkins job — Figure 1

2. Give a name to the Job.

3. Select Freestyle project.

4. Click on OK button.

Setting up a new Jenkins job — Figure 2

5. Then it will redirect to the Job Configuration page.

6. In here, navigate to the Source Code Management section.

7. Select Git.

8. Provide Repository URL and Credentials of the repository.

Source Code Management Configurations

9. Then navigate to the Build section.

10. Click on add Build Step drop-down and select Execute Windows batch command.

Build Step Configurations — Figure 1

11. Then type following command in the Command text box.
mvn test-compile gauge:execute -DspecsDir="specs" -Denv="QA"

Note: -Denv="QA" refers the property file in env folder qa.properties
If you don’t need to specify the environment, just ignore that segment. Then Gauge will pick default.properties as the default property file.

Build Step Configurations — Figure 2

12. Click on Save button.

Execute a Job

1. Go to Jenkins Dashboard and click on the created project.

2. Then click on the Build Now button.

Execute a Job

3. Then it will trigger a new build.

4. You can see the console output while the execution is going.

5. After the execution is completed, Gauge reports can be viewed inside the Jenkins Workspace.

Happy Automation !!!

--

--

Osanda Deshan Nimalarathna
Test Automation Master

Founder of MaxSoft | RPA Solution Architect | Open-source Contributor | Automation Framework Developer | Technical Specialist