Jenkins is a powerful tool for continuous integration and continuous delivery (CI/CD). It allows you to automate the process of building, testing, and deploying your application. In this article, we will cover how to create an empty test folder in Jenkins workspace. This is useful for organizing your test results and making them easily accessible.
Prerequisites
Before we begin, you will need to have the following:
- A Jenkins instance up and running
- A Jenkins job that generates test results
Creating the Test Folder
To create an empty test folder in Jenkins workspace, follow these steps:
- Navigate to your Jenkins dashboard and select the job that generates test results.
- Click on the
Configurebutton to edit the job configuration. - Scroll down to the
Buildsection and click on theAdd build stepbutton. - Select the
Execute shelloption from the drop-down menu. - In the
Commandfield, enter the following command:mkdir -p ${WORKSPACE}/test-results/unitThis command will create a directory named
test-resultsin the Jenkins workspace, and a subdirectory namedunitinside it. - Click on the
Savebutton to save the changes.
Verifying the Test Folder
To verify that the test folder has been created, follow these steps:
- Run the Jenkins job that generates test results.
- Once the job has completed, navigate to the
Test Resultssection of the job page. - Click on the
Test Resultlink to view the test results. - In the test results page, you should see the
test-resultsdirectory listed in the left-hand navigation menu. - Click on the
test-resultsdirectory to view the subdirectories. You should see theunitdirectory that we created in the previous section.
Adding Test Results to the Test Folder
Now that we have created the test folder, we can add test results to it. The process of adding test results to the test folder will vary depending on the testing framework that you are using. In this section, we will cover how to add test results to the test folder for JUnit tests.
- Navigate to your Jenkins dashboard and select the job that generates JUnit test results.
- Click on the
Configurebutton to edit the job configuration. - Scroll down to the
Post-build Actionssection and click on theAdd post-build actionbutton. - Select the
Publish JUnit test result reportoption from the drop-down menu. - In the
Test report XMLsfield, enter the following pattern:${WORKSPACE}/test-results/unit/*.xmlThis pattern will match all the JUnit test result XML files in the
unitdirectory that we created earlier. - Click on the
Savebutton to save the changes.
Viewing Test Results
To view the test results, follow these steps:
- Run the Jenkins job that generates JUnit test results.
- Once the job has completed, navigate to the
Test Resultssection of the job page. - Click on the
Test Resultlink to view the test results. - In the test results page, you should see the test results grouped by test suite and test case.
In this article, we have covered how to create an empty test folder in Jenkins workspace, and how to add test results to the test folder. This is useful for organizing your test results and making them easily accessible. By following the steps outlined in this article, you can create a test folder in your Jenkins workspace and start adding test results to it.
References
| Title | URL |
|---|---|
| Jenkins - Getting Started | https://www.jenkins.io/doc/tutorials/build-a-java-app-with-maven/ |
| Jenkins - Publish JUnit Test Result Report | https://www.jenkins.io/doc/pipeline/steps/junit/ |