Maven + Jenkins
To integrate Maven with Jenkins, follow these steps:
Install the Maven Integration plugin:
Access the Jenkins web interface.
Click on "Manage Jenkins" in the left-hand side menu.
Select "Manage Plugins" from the dropdown.
Navigate to the "Available" tab.
Search for "Maven Integration" in the filter box.
Check the box next to "Maven Integration" plugin.
Click on the "Install without restart" button.
Configure the Maven installation in Jenkins:
Go back to the Jenkins dashboard.
Click on "Manage Jenkins" in the left-hand side menu.
Select "Global Tool Configuration" from the dropdown.
Scroll down to the "Maven" section.
Click on "Add Maven".
Provide a name for the Maven installation (e.g., "Maven 3.x.x").
Specify the MAVEN_HOME directory or let Jenkins install it for you.
Click on the "Save" button.
Create a new Jenkins job:
On the Jenkins dashboard, click on "New Item" on the left-hand side.
Enter a name for your job and select "Freestyle project".
Click "OK" to proceed.
Configure the job:
Source Code Management: Select the appropriate SCM (e.g., Git, Subversion) and configure the repository details.
Build section: Add a build step by clicking on the "Add build step" dropdown and selecting "Invoke top-level Maven targets".
Maven Version: Choose the Maven installation you configured in step 2.
Goals: Enter the Maven goals you want to execute (e.g., clean install).
POM: Specify the path to the POM file relative to the repository root (e.g., pom.xml).
Save the job configuration.
Build the job:
On the Jenkins dashboard, click on the job name to navigate to its details page.
Click on "Build Now" to trigger the build.
Jenkins will now execute the Maven goals specified in the job configuration, using the configured Maven installation. You can view the build output, check the build status, and access other features provided by Jenkins for continuous integration and delivery.
By integrating Maven with Jenkins, you can automate your build and deployment processes, execute Maven goals, generate reports, and manage dependencies in your projects.
Last updated