Creating a pipeline script from Jenkins
You must create a pipeline script to run test assets that are available in the HCL DevOps Test Hub (Test Hub) project from the Jenkins Pipeline project.
Before you begin
You must have completed the following tasks:
-
Installed the Test Hub Jenkins plugin on the Jenkins server. See Installing the Test Hub Jenkins plugin.
-
Generated an offline user token from Test Hub. See Managing access to DevOps Test Hub.
-
Created a Jenkins Pipeline project.
Procedure
- Open your Jenkins Pipeline project from the list.
- Click Configure, and then select the Pipeline tab.
- Click Pipeline Syntax to generate a pipeline script.
- Select the step: General Build Step option from the drop-down list in the Sample Step field.
- Select the Run HCL DevOps Test Hub test option from the drop-down list in the Build Step field.
-
Provide the details about the test run for the fields in the following
table:
The following table lists the required fields that you must provide to run the test from Jenkins:
Fields Action Name Enter a name for the Jenkins build step.
Server URL Enter the URL of Test Hub.
The format of the URL is as follows: https://hostname.
Offline Token Enter the offline user token that you generated from Test Hub. Field Description Asset Type Use this field to select the test asset type that you want to run from the Asset Type drop-down list.
Branch Select the branch from the drop-down list.
The Branch drop-down list displays the branches that are available in the corresponding project of Test Hub.
Datasets Use this field to enter the path to the dataset if you want to replace the values of the dataset during a test run.
You must ensure that both original and new datasets are in the same workspace and have the same column names. When you enter a value for the Datasets field, you must also include the path to the dataset. The path must be in the following format:
/project_name/ds_path/original_ds.csv:/project_name/ds_path/new_ds.csv
Note: You can override multiple datasets that are saved in a different project by adding multiple paths to the dataset separated by a semicolon.Labels Use this field to add labels to test results when the test run is complete.
You can add multiple labels to a test result separated by a comma.
For example, label1, label2
After the test run is complete, then the values provided in the Labels field are displayed on the Results page of Test Hub.
Project Use this field to select a project from the drop-down list.
The Project drop-down list displays the projects that are available in the corresponding team space of Test Hub.
Note: The Project drop-down list displays the projects where you are an Owner or a member of Test Hub. You must be an Owner or a Tester of the project that is available in the team spaces to run the tests from the Jenkins server.Secrets Use this field to select the Secret from the Classification drop-down list if you created secrets for your project to use Secrets at test run time.
The Secrets field is mandatory only if you select one of the following options in the Asset Type field:- APISUITE
- APITEST
- APISTUB
- POSTMAN
The following message is displayed when you select any other asset type than preceding list:
You can select Secrets only if you are running tests of type APISUITE, APITEST, APISTUB, or POSTMAN.
Team Space Use this field to select the name of the team space from the drop-down list.
The Team Space drop-down list displays the names of the team spaces if you are an Owner or a member of the team space.
Test Use this field to select the required test that you want to run from the drop-down list.
The Tests drop-down list displays the available test assets from the corresponding branch in the following format:
Project_name [Path: the path of the test assets] [Repo: URL of the Git repository that the test belongs to]
Note: After you select the test details from the Tests drop-down list if you want to change the URL of Test Hub, offline user token, or the project in the Jenkins Build step, then you must delete the build step and add a new build step.Test Environment Use this field to select an environment from the drop-down list.
The Test Environment field displays the available test environments from Test Hub.
The Test Environment field is mandatory only if you select one of the following options in the Asset Type field:- APISUITE
- APITEST
- APISTUB
- POSTMAN
The following message is displayed when you select any other asset type than preceding list:
You can select Test Environment only if you are running tests of type APISUITE, APITEST, APISTUB, or POSTMAN.
Use Custom Trust Store Select this checkbox if you used an internal CA certificate and imported the certificate to the custom trust store. You can then enter the file path of your trust store followed by the file name in the Custom Trust Store Path field.
Select the Use Custom Password for the Trust Store checkbox if you modified the trust store password, and then enter the new password in the Custom Trust Store Password field.Note: If you did not modify the trust store password, you must clear the Use Custom Password for the Trust Store checkbox.Variables Use this field to enter the name of the variable and its value if your test requires variables during the test run time.
You must enter the variables in the following format:
name_of_the_variable=value_of_the_varibale
You can add multiple variables to the test run separated by a semicolon.
For example, varname1=value1;varname2=value2
- Click Generate Pipeline Script and copy the script that you created for the build step to use it in the sample script.