adding custom parameters to configure publishers in withMaven pipeline step

225 views
Skip to first unread message

Valentina Armenise

unread,
Mar 22, 2017, 6:13:23 AM3/22/17
to Jenkins Users
Hi,

I'd like to customize the withMaven  step from the Pipeline Maven Plugin to take as input the parameters which you would normally pass to a publisher. Specifically I'd like to be able to do something like

step([$class: 'FindBugsPublisher', canRunOnFailed: true, defaultEncoding: 'UTF-8', excludePattern: '', healthy: '', includePattern: '', pattern: '**/target/findbugsXml.xml', shouldDetectModules: true, unHealthy: '', unstableTotalAll: '0', useStableBuildAsReference : true])

In order to define the thresholds or other things..

Looking at the code, does not seem to be possible today. Is it correct?

Cyrille Le Clerc

unread,
Apr 14, 2017, 6:37:40 AM4/14/17
to Jenkins Users, mark.la...@connectis.nl, Alvaro Andres Lobato Moreno
Hello Valentina,

We are going to look at this soon.

We have requests to have a more elegant solution to disable reporters (see JENKINS-43596 Add withMaven options for skipping).
We don't know yet what would be the right syntax to add configuration flags that could be consumed by the withMaven step itself or by reporters (JUnit, archiver, FindBugs, Task Scanner...).

Cyrille

Cyrille Le Clerc

unread,
May 12, 2017, 5:25:41 AM5/12/17
to Jenkins Users, mark.la...@connectis.nl, alo...@cloudbees.com
Idea discussed with Alvaro Lobato: introduce an "options" Map<String, Object> as a parameter of withMaven(). We will also make these options configurable at the Jenkins global level then at the folder level. 

See sample below

node {
    stage ("build") {
        withMaven(
            maven: 'maven-3.3.9', 
            mavenSettingsConfig: 'maven-settings-for-gameoflife',
            options: [
                skipArchiveGeneratedArtifacts: true, 
                fingerprintDependenciesExclude: "org.springframework.*"]
            ) {
            sh "mvn clean package"

Cyrille Le Clerc

unread,
May 12, 2017, 2:16:46 PM5/12/17
to Jenkins Users, mark.la...@connectis.nl, alo...@cloudbees.com
Note: Mark Lagendijk proposed a hierarchical approach for options in JENKINS-43596. It is a bit more sophisticated, more standardized ... but a bit more verbose than what we tried in my previous post

Hierarchical & standardized model

withMaven(
   maven: 'maven-3.3.9', 
   mavenSettingsConfig: 'maven-settings-for-gameoflife',
   options: [
     artifactReporter: [
       disabled: true // default = false
     ],
     someOtherReporter: [
       options: [] // whatever options this reporter accepts
     ] 
   ]
) {

   sh "mvn package"
}

Flat & not-standardized model

withMaven(
   maven: 'maven-3.3.9', 
   mavenSettingsConfig: 'maven-settings-for-gameoflife',
   options: [
     skipArchiveGeneratedArtifacts: true, 
     fingerprintDependenciesExclude: "org.springframework.*" 
   ]
) {

   sh "mvn package"

Baptiste Mathus

unread,
May 16, 2017, 4:52:55 AM5/16/17
to jenkins...@googlegroups.com, mark.la...@connectis.nl, alo...@cloudbees.com
I tend to prefer the hierarchical approach. IMO it should /scale/ better, being more readable/organized. Without this, you'll indeed end up with very long options using camelCase. 

--
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/e7b7a2c1-067c-487a-945b-53df9babc97b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Cyrille Le Clerc

unread,
May 16, 2017, 8:13:32 AM5/16/17
to Jenkins Users, mark.la...@connectis.nl, alo...@cloudbees.com, m...@batmat.net
Jesse Glick has answered in https://issues.jenkins-ci.org/browse/JENKINS-43596

I am working on something that will look like withMaven(options: [artifacts(), findbugs(unstableOnThreshold: 5), tests(excludes: '**/PerformanceTest')]) {…}

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

Cyrille Le Clerc

unread,
May 21, 2017, 1:35:53 PM5/21/17
to Jenkins Users, mark.la...@connectis.nl, alo...@cloudbees.com, m...@batmat.net
Configuration options to override default settings have been added for the OpenTaskScanner in pipeline-maven-2.3.1-beta-1.

It looks like: 
withMaven(options:[openTasksPublisher(
       pattern:'src/main/java', excludePattern:'src/main/java/excluded',
       ignoreCase:true, asRegexp:false, 
       lowPriorityTaskIdentifiers:'minor', normalPriorityTaskIdentifiers:'todo', highPriorityTaskIdentifiers:'fixme')]) {

           sh 'mvn package verify'
}

Cyrille
Reply all
Reply to author
Forward
0 new messages