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.
Setting up a CI pipeline can be a daunting task, but with the right tools it can be relatively simple. In this article, we will show you how to set up a CI pipeline using Jenkins and IntelliJ.
The first step is to create a GitHub repository for your project. To do this, head over to GitHub and create a new repository.
Name your repository and click "Create repository".
Next, we need to create a Jenkins job. A Jenkins job is a task that Jenkins can execute. In our case, the Jenkins job will checkout our code from GitHub, build it, and run our tests.
To create a Jenkins job, head over to your Jenkins server and click "New Job".
Give your job a name and select "Freestyle project".
Click "OK".
On the next page, scroll down to the "Source Code Management" section and select "Git".
In the "Repository URL" field, enter the URL of your GitHub repository.
Scroll down to the "Build" section and click "Add build step". Select "Execute shell".
In the "Command" field, enter the following command:
mvn clean install
This command will clean our project, install any dependencies, and run our tests.
Scroll down to the "Post-build Actions" section and click "Add post-build action". Select "Publish JUnit test result report".
In the "Test report XMLs" field, enter the following:
**/target/surefire-reports/*.xml
This will tell Jenkins to publish the results of our tests.
Click "Save".
Now that we have our Jenkins job set up, we need to configure our IDE. In this section, we will show you how to set up IntelliJ to trigger a build on our Jenkins server when we make changes to our code.
Open IntelliJ and navigate to the "File" menu. Select "Settings".
In the "Settings" window, navigate to "Build, Execution, Deployment" > "Continuous Integration". Select "Jenkins".
In the "Jenkins URL" field, enter the URL of your Jenkins server.
In the "Project name" field, enter the name of your Jenkins job.
Click "OK".
Now that our Jenkins job is set up and our IDE is configured, we are ready to trigger a build. To do this, make a change to your code and push it to GitHub.
Once you push your code to GitHub, Jenkins will automatically detect the change, checkout the code, build it, and run the tests.
You can view the results of the build by clicking on the "build" link in the "Build History" section.

In this article, we showed you how to set up a CI pipeline using Jenkins and IntelliJ. While this is a simple pipeline, it can be easily extended to include additional steps, such as deploying to a staging or production environment.