Integrating TestProject with Jenkins CI

While automated tests have a value of their own, integrating them in your CI flow can have a significant impact on your product’s overall quality. Ensuring that your automation (or at least part of it) will be executed each time there is a version build, will provide much broader insights into the stability of the product. TestProject test automation platform allows easy integration with Jenkins CI by using a simple Jenkins plugin.

This article will guide you step by step through the process of setting TestProject-Jenkins integration.

Prerequisites

  1. You need to have a TestProject account. Don’t worry, it’s FREE.
  2. Jenkins CI server up and running.

Tutorial Overview

  1. Installing TestProject Jenkins Plugin
  2. Creating a TestProject API Key
  3. Configuring the TestProject Jenkins Plugin
  4. Running a TestProject Job from Jenkins
    1. Getting all the Parameters
    2. The Freestyle Approach
    3. The Pipeline Approach
    4. The “Wait to finish” Parameter
  5. Reviewing Execution Results
  6. Conclusion

1. Installing TestProject Jenkins Plugin

TestProject’s Jenkins plugin is available in the Jenkins plugin index and is simply installed from Jenkins UI.

  • Open your favorite browser and navigate to your Jenkins server.
  • Choose Manage Jenkins → Manage Plugin → Available Tab.
  • Filter “TestProject” → Select TestProject plugin and hit Install without Restart.

That’s it! After a few seconds, the plugin will be installed in your Jenkins server.

TestProject-Jenkins-1

 

2. Creating a TestProject API Key

Now it’s time to integrate TestProject. For that, you will have to create an API key that your Jenkins server will use to trigger your automation jobs.

  • Open the TestProject application and go to Developers → API.
  • Create a new API key (let’s call it Jenkins) and grant it the access you desire. API keys can have unrestricted access which means that they can be used in any project or have access to specific projects (this option is only available to account administrators and no worries, you can always edit the permissions later).

TestProject-Jenkins-2

  • After the new API key has been created, copy it and head back to your Jenkins server.

TestProject-Jenkins-3

3. Configuring the TestProject Jenkins Plugin

Now let’s configure the TestProject Jenkins plugin and set the newly created API key. This is a one-time step (unless you wish to change your key at some point), your key will be used for every job triggered by a Jenkins build.

  • In Jenkins, choose Manage Jenkins → Configure System.
  • Locate the TestProject configuration section, paste your key into the API Key field and hit Save.

TestProject-Jenkins-4

4. Running a TestProject Job from Jenkins

After installing the TestProject Jenkins plugin, generating an API key and configuring it to be used by Jenkins, you are ready to go ahead and incorporate your automated tests in the CI process. The plugin supports the two most popular approaches: Freestyle & Pipeline.

4.1. Getting all the Parameters

In order to run a TestProject job remotely, all you need besides the API key which we’ve already configured are the Project ID and the Job ID which you want to run. These IDs are unique strings and the easiest way to obtain them is by using TestProject application UI. To get the ID of the project just navigate to the homepage and copy the ID from the project’s context menu. The job ID is available in its context menu as well.

TestProject-Jenkins-5TestProject-Jenkins-6

 

 

 

 

 

 

 

 

 

 

 

 

Note: If you cannot locate the Copy ID option is your menus, please make sure that you have at least one API key defined in the account.

Now let’s head back to Jenkins and create a new CI job or open an existing one.

4.2. The Freestyle Approach

For freestyle projects:

  • Add a new TestProject Job build step:TestProject-Jenkins-7

 

  • Provide the parameters to be used and save:TestProject-Jenkins-8

4.3. The Pipeline Approach

For pipeline projects use the following syntax:

runtpjob jobId: 'YOUR_JOB_ID', projectId: 'YOUR_PROJECT_ID', waitJobFinishSeconds: 1800

4.4. The “Wait to finish” Parameter

The wait parameter is optional in both cases. The valid values are 0 or 10 and higher (the value is in seconds):

  • Setting the value to 0 or omitting the parameter in the pipeline will run the TestProject job without waiting for it to finish. The result of the TestProject job will not affect the result of the Jenkins job.
  • Setting the value to 10+ will wait for TestProject job to finish within the defined time frame. In case the automation didn’t finish running in the defined period or the tests failed, the Jenkins job will be marked failed as well.

 

5. Reviewing Execution Results

After the execution completes, you will see console entries regarding the execution process. At the end, a direct link to the generated report will be present.

TestProject-Jenkins-9

TestProject report of the executed job will reflect the Jenkins CI build information.

TestProject-Jenkins-10

 

6. Conclusion

In this article, we’ve installed TestProject‘s plugin for Jenkins CI, added a step to run our automated jobs and reviewed the results. There is no doubt that CI tools like Jenkins have revolutionized the way we build and deploy our software. These tools dramatically shortened the time span between introducing a new feature or a bug fix to our product and the time the new version is ready to be tested/used. Test automation allows us to increase the coverage of what is being tested in every new release which in turn improves the quality of our software. Incorporating test automation into the CI process takes another step towards better, more stable products!

 

Happy Testing!

Feel free to leave your comments below  ➡