OverviewOne of the great things about Maven is that it provides a standard project and build layout, along with a standard set of "goals." Not only does this make it easier for developers to get up to speed on a new project, but it also allows Jenkins to provide special support for Maven projects, reducing the configuration needed while enhancing the build report automatically. That is the goal of the Maven plugin for Jenkins.
The central feature of the Maven plugin for Jenkins is the Maven 2/3 project type. Thanks to the Maven project object model (POM), this project type can automatically provide the following features:
- Archive artifacts produced by a build
- Publish test results
- Trigger jobs for projects which are downstream dependencies
- Deploy your artifacts to a Maven repository
- Breakout test results by module
- Optionally rebuild only changed modules, speeding your builds
Requirements for Plugin UseAll Jenkins releases have the Maven plugin included. You must also have at least one Maven installation.
How to Use ItFirst, you must configure a Maven installation (this step can be skipped if you are using DEV@cloud). This can be done by going to the system configuration screen (Manage Jenkins-> Configure System). In the "Maven Installations" section, 1) click the Add button, 2) give it a name such as "Maven 3.0.3" and then 3) choose the version from the drop down.
Now, just click build now, and click on the progress bar in the left hand "Build Executor Status" to watch Jenkins install Maven, checkout your project, and build it using Maven. The build output should look something like this:
- A link to the module's workspace
- The module's artifacts
- A clickable test result trend
- Recent changes (just for that module!)
Finally, if we had configured Jenkins to build any downstream dependencies of this project, they would automatically start building after this build completed.
If you are using the Maven plugin, you should also investigate the M2 Release Plugin for automating releases with one click. The M2 Extra Steps plugin will let you run arbitrary build steps before and after your build. Finally, the new Config File Provider plugin lets you maintain different settings.xml which can be referenced by your Maven builds.