New Pipeline Maven plugin

511 views
Skip to first unread message

Álvaro Lobato

unread,
Aug 11, 2016, 12:33:19 PM8/11/16
to Jenkins Users

Hello everyone,

I'd like to introduce you to the new Pipeline Maven plugin . The intention of this plugin is to help using maven from pipeline, setting up a maven environment by using a withMaven step. This environment can later be called with sh or bat step.

The supported configuration parameters are:
  • Maven Installation
  • JDK
  • Maven Settings Config (Config File Provider Plugin)
  • Maven Settings File Path 
  • Maven JVM Opts 
  • Maven Local Repository 
The step can be used used directly on a node or in a docker.inside.

Currently it is in an early stage of development and I've just released the first beta version, already available in the update center.

This is the start point for a more feature rich integration between pipeline and maven.

You can find more information on the wiki page: Pipeline Maven plugin 

Thanks
Alvaro.

Daniel Beck

unread,
Aug 11, 2016, 2:02:57 PM8/11/16
to jenkins...@googlegroups.com

> On 11.08.2016, at 18:33, Álvaro Lobato <alvaro...@gmail.com> wrote:
>
> released the first beta version, already available in the update center

Experimental update site only:

https://jenkins.io/blog/2013/09/23/experimental-plugins-update-center/


Álvaro Lobato

unread,
Aug 11, 2016, 3:19:33 PM8/11/16
to jenkins...@googlegroups.com

Yes, thanks Daniel.

niristotle okram

unread,
Aug 11, 2016, 4:06:31 PM8/11/16
to jenkins...@googlegroups.com
Assuming maven was already installed in the node & have the files configured (settings.xml, local repo etc) from the TOOLS setting of jenkins.. 
Will this plugin override those settings? 

 withMaven(mavenInstallation: 'M3', mavenLocalRepo: '.repository', mavenSettingsConfig: 'maven-settings-for-gameoflife') {
        // Run the maven build
        sh "mvn clean install"
    }


And is there any plan for the maven release plugin in pipeline? At the moment i am using the 'bat' to call the goals for release:prepare and release:perform   


Thanks





--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/81089a41-3bdf-47a4-bdad-b4424d27341b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
nirish okram

Álvaro Lobato

unread,
Aug 12, 2016, 4:27:33 AM8/12/16
to Jenkins Users
It will override the settings only if you decide to, by specifying a settings parameter. If you don't specify, it will use the already defined ones.

As for the release plugin I'm not aware of any plan for it on pipeline, are you having problems with  sh/bat mvn release:prepare release:perform ?
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.



--
Regards
nirish okram

Will Currie

unread,
Aug 12, 2016, 7:43:37 PM8/12/16
to Jenkins Users
Nice. It seems to non-pipeline/'old-school'/regular jenkins maven build has support for tracking fingerprints of artefacts used and produced by any given maven build. I'm taking about the work that seems to be done by MavenFingerprinter. If I understand correctly this allows you to see builds upstream and downstream of any given maven build.

Any thoughts on how this might fit into the pipeline builds? The pipeline tutorial shows how to configure fingerprints for build outputs (**/target/*.jar). It doesn't seem to cover tracking fingerprints for what it consumes.

Thanks.

Cyrille Le Clerc

unread,
Aug 15, 2016, 11:44:41 AM8/15/16
to Jenkins Users
Hello Will,

Fingerprint and reports rendering are things we would like to see in forthcoming releases of this plugin. We hope that the community will help on this kind of feature.

For the moment, we unfortunately have to use the following verbose steps:

step([$class: 'ArtifactArchiver', artifacts: 'gameoflife-web/target/*.war'])
step([$class: 'WarningsPublisher', consoleParsers: [[parserName: 'Maven']]])
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
step([$class: 'JavadocArchiver', javadocDir: 'gameoflife-core/target/site/apidocs/'])
...

Cyrille

Cyrille Le Clerc

unread,
Aug 15, 2016, 12:08:03 PM8/15/16
to Jenkins Users
Hello ok999,

> Assuming maven was already installed in the node & have the files configured (settings.xml, local repo etc) from the TOOLS setting of jenkins.. 
> Will this plugin override those settings? 

Yes, "withMaven(){}" will override all the settings that you define with the wrapper. We do it creating a shell wrapper of the "mvn" / "mvn.bat" command.

If you specify a "jdk" with "withMaven(jdk: 'my-jdk'){}" then we will override "JAVA_HOME" and add this new "$JAVA_HOME/bin" to the "PATH"
If you specify a "mavenInstallation" then we will override "MAVEN_HOME", "M2_HOME", we will ensure that the "mvn" wrapper that we create with "withMaven()" points to this desired MAven installation.
If you specify a "mavenSettingsConfig", we will pass it as a "--settings" when invoking the "mvn" executable
If you specify a "mavenLocalRepo", we will pass the system property "-Dmaven.repo.local="

You can see all these details enabling a FINE logger on "org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution"



> And is there any plan for the maven release plugin in pipeline? At the moment i am using the 'bat' to call the goals for release:prepare and release:perform   

We focus for the moment on covering as many Maven use cases as possible with the "withMaven(...){}" wrapper. We hope that a Maven execution step will appear soon.

I feel that a Maven release is already pretty straight forward with the "withMaven(...){}" wrapper. The following code actually works:

node {
    withMaven(mavenSettingsConfig: 'maven-settings-for-game-of-life', mavenInstallation: 'M3', jdk: 'Oracle JDK 8') {
        git 'https://github.com/cyrille-leclerc/my-spring-boot-app.git'
        sh "mvn release:prepare release:perform"
    }
}


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.



--
Regards
nirish okram

Sverre Moe

unread,
Nov 21, 2016, 6:27:54 AM11/21/16
to Jenkins Users
I am enquiring the status of Pipeline Maven Integration Plugin.

Is it still under development? Is it production ready?

Created by the Snippet Generator:
withMaven(jdk: 'jdk1.8.0_102', maven: 'apache-maven-3.3.3', mavenLocalRepo: '', mavenOpts: '', mavenSettingsFilePath: '') {
    sh
"mvn clean deploy"
}

If I do not specify parameter jdk it will choose Java 7, which Jenkins has listed as JDK number 2. While Java 8 is number 1 in the list. Does it pick the last in the list of JDKs?

Cyrille Le Clerc

unread,
Nov 21, 2016, 6:33:17 AM11/21/16
to Jenkins Users
Hello Sven,

> Is it still under development? Is it production ready?

Yes we are working at improving / enhancing it and yes we think it is production ready. There are already many users.

> If I do not specify parameter jdk it will choose Java 7, which Jenkins has listed as JDK number 2. While Java 8 is number 1 in the list. Does it pick the last in the list of JDKs?

If you don't specify a JDK, the shell command will pick the default JVM of your PATH. The current strategy for default values is to use the default of the build agent (ignoring Jenkins global settings).

We discuss on https://issues.jenkins-ci.org/browse/JENKINS-39407 the idea to offer another strategy for defaults that would rely on the Jenkins Defaults.

Cyrille
Reply all
Reply to author
Forward
0 new messages