In this guide we will look at setting up a modern CI workflow with Jenkins to run your automated tests and collect & report test results. Running your tests as part of your Jenkins pipeline is a great way to make sure that new changes committed to your project repository are automatically checked and verified.
It doesn't matter whether you are adding your automated tests to your main project pipeline or if you prefer to set up a separate pipeline just for your tests: running your tests with a CI pipeline ensures consistent & regular test execution and enables you to make the test results accessible to your entire team. So let's get started!
Initial Pipeline & Project Repository
For this article we are assuming you have a working Jenkins environment and Git service (we just use GitHub ourselves for this guide). Setting up Jenkins is outside of the scope of this guide and there are many good resources available on how to get started, including the official Jenkins documentation. Usually a good way to get started is to use the official Docker images, as you don't need to install anything yourself then.
We start by creating a new Git repository called example-jenkins-automation
in GitHub and create a new pipeline in Jenkins called example-pipeline
(using the Pipeline project type). We also configure the pipeline in Jenkins to connect to our Git repository and automatically retrieve the Jenkins configuration file Jenkinsfile
from the repository (learn more).
We have published this project's repository on GitHub so you can always review all files there. Here is the initial Jenkinsfile
we start with: