Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39407

Use system default Maven, Maven Settings if not specified

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Currently, when you use the ``withMaven`` step, you need to specify the Maven installation. Furthermore, if you've configured, using the Managed Files and Global Tools Configuration, a maven settings.xml, you need to specify an ugly ID for that.

      For example:
      withMaven(maven: 'Maven 3.3', mavenSettingsConfig: 'ecbd05c9-e03e-4ccb-9aa1-242f9f1a423c')

      { sh "mvn clean verify -B" }

      It would be good if these could both be defaulted - at least, the mavenSettingsConfig, which doesn't have to be specified with the freestyle Maven Builder.

        Attachments

          Issue Links

            Activity

            Hide
            cleclerc Cyrille Le Clerc added a comment - - edited

            This has been debated, some people preferred "stock" by default, others preferred "jenkins global maven config by default".
            We had in mind to add a global configuration parameter in "manage jenkins" to define the default behavior".

            Show
            cleclerc Cyrille Le Clerc added a comment - - edited This has been debated, some people preferred "stock" by default, others preferred "jenkins global maven config by default". We had in mind to add a global configuration parameter in "manage jenkins" to define the default behavior".
            Hide
            twasink Robert Watkins added a comment -

            Well, it's stock by default unless you, as the Jenkins administrator, change the Jenkins global maven config.

            As a Jenkins administrator, I must say that if I change the global maven config, I expect it to be used by default. If I didn't want it to be used by default, I wouldn't have made it the global maven config.

            Basically, what I'm looking for here is parity-of-behaviour with the freestyle plugin.

            Show
            twasink Robert Watkins added a comment - Well, it's stock by default unless you, as the Jenkins administrator, change the Jenkins global maven config. As a Jenkins administrator, I must say that if I change the global maven config, I expect it to be used by default. If I didn't want it to be used by default, I wouldn't have made it the global maven config. Basically, what I'm looking for here is parity-of-behaviour with the freestyle plugin.
            Hide
            cleclerc Cyrille Le Clerc added a comment -

            So, if the maven settings file (resp maven global settings file) is not define in "withMaven(...)", then we would default to the default strategy defined on Jenkins global config screen (jenkins.mvn.GlobalMavenConfig):

            Show
            cleclerc Cyrille Le Clerc added a comment - So, if the maven settings file (resp maven global settings file) is not define in " withMaven(...) ", then we would default to the default strategy defined on Jenkins global config screen (jenkins.mvn.GlobalMavenConfig): jenkins.mvn.GlobalMavenConfig#getSettingsProvider() jenkins.mvn.GlobalMavenConfig#getGlobalSettingsProvider()
            Hide
            twasink Robert Watkins added a comment -

            That's pretty much the behaviour I would expect.

            Show
            twasink Robert Watkins added a comment - That's pretty much the behaviour I would expect.
            Hide
            cleclerc Cyrille Le Clerc added a comment - - edited

            Jesse Glick we seem to have a problem with "AbstractBuild" versus "WorkflowRun".

            Maven default settings are handled by jenkins.mvn.SettingsProvider#supplySettings(AbstractBuild<?, ?> build, TaskListener listener) which is based on "AbstractBuild" when pipeline is based on "WorkflowRun".

            As we want to use jenkins.mvn.SettingsProvider#supplySettings() in "withMaven(){...}", does it seem reasonable to refactor jenkins.mvn.SettingsProvider#supplySettings(AbstractBuild<?, ?> build, TaskListener listener) into jenkins.mvn.SettingsProvider#supplySettings(Run<?, ?> build, TaskListener listener)?

            Show
            cleclerc Cyrille Le Clerc added a comment - - edited Jesse Glick we seem to have a problem with " AbstractBuild " versus " WorkflowRun ". Maven default settings are handled by jenkins.mvn.SettingsProvider#supplySettings(AbstractBuild<?, ?> build, TaskListener listener) which is based on " AbstractBuild " when pipeline is based on " WorkflowRun ". As we want to use jenkins.mvn.SettingsProvider#supplySettings() in " withMaven(){... }", does it seem reasonable to refactor jenkins.mvn.SettingsProvider#supplySettings(AbstractBuild<?, ?> build, TaskListener listener) into jenkins.mvn.SettingsProvider#supplySettings(Run<?, ?> build, TaskListener listener) ?
            Hide
            jglick Jesse Glick added a comment -

            Yes we would need to do that.

            Show
            jglick Jesse Glick added a comment - Yes we would need to do that.
            Hide
            cleclerc Cyrille Le Clerc added a comment -

            Jesse Glick could you have a look at https://github.com/jenkinsci/jenkins/pull/2678 to verify it this refactoring of jenkins.mvn.SettingsProvider#supplySettings() to support pipeline jobs is moving in the right direction?

            Show
            cleclerc Cyrille Le Clerc added a comment - Jesse Glick could you have a look at https://github.com/jenkinsci/jenkins/pull/2678 to verify it this refactoring of jenkins.mvn.SettingsProvider#supplySettings() to support pipeline jobs is moving in the right direction?
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Cyrille Le Clerc
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java
            src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnGlobalSettingsProvider.java
            src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnSettingsProvider.java
            http://jenkins-ci.org/commit/config-file-provider-plugin/58621a3f59c16401070853497640c7f0dd7e4ec9
            Log:
            JENKINS-40665JENKINS-39407 Support Maven Settings Provider and Maven Global Settings Provider for pipeline

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: pom.xml src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnGlobalSettingsProvider.java src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnSettingsProvider.java http://jenkins-ci.org/commit/config-file-provider-plugin/58621a3f59c16401070853497640c7f0dd7e4ec9 Log: JENKINS-40665 JENKINS-39407 Support Maven Settings Provider and Maven Global Settings Provider for pipeline
            Hide
            cleclerc Cyrille Le Clerc added a comment -

            FYI I am working on this, I need first to get a change in jenkins-core merged. See JENKINS-40665

            Show
            cleclerc Cyrille Le Clerc added a comment - FYI I am working on this, I need first to get a change in jenkins-core merged. See JENKINS-40665
            Show
            cleclerc Cyrille Le Clerc added a comment - - edited Work in progress  https://github.com/jenkinsci/pipeline-maven-plugin/pull/31 https://github.com/jenkinsci/jenkins/pull/2818  
            Show
            cleclerc Cyrille Le Clerc added a comment - See https://github.com/jenkinsci/pipeline-maven-plugin/pull/44
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Cyrille Le Clerc
            Path:
            jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java
            jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java
            http://jenkins-ci.org/commit/pipeline-maven-plugin/a0d182bb1257e5d96f7d4a15434493b5cb3bec82
            Log:
            Merge pull request #44 from jenkinsci/JENKINS-40665-3

            JENKINS-39407 Use Maven Settings and Maven Global Settings defined in the Jenkins Global Configuration

            Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/2eabb4b13a8e...a0d182bb1257

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java http://jenkins-ci.org/commit/pipeline-maven-plugin/a0d182bb1257e5d96f7d4a15434493b5cb3bec82 Log: Merge pull request #44 from jenkinsci/ JENKINS-40665 -3 JENKINS-39407 Use Maven Settings and Maven Global Settings defined in the Jenkins Global Configuration Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/2eabb4b13a8e...a0d182bb1257
            Hide
            cleclerc Cyrille Le Clerc added a comment - - edited

            Robert Watkins could you test https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-parent-2.1.0-beta-1 ? It's a beta version, it does not appear in the update center unless you have enable the "experimental" update center.

            You can verify that the settings are used with "mvn help:effective-settings".

            The log message indicating that Maven settings and/or Maven Global Settings are injected look like

            [withMaven] use Maven global settings provided by the Jenkins global configuration 'global-maven-settings' 
            [withMaven] use Maven global settings.xml 'global-maven-settings' with Maven servers credentials provided by Jenkins (replaceAll: false): [mavenServerId: 'global-credentials-bitbucket', jenkinsCredentials: 'bitbucket-credentials', username: 'cleclerc', type: 'UsernamePasswordCredentialsImpl']
            
            Show
            cleclerc Cyrille Le Clerc added a comment - - edited Robert Watkins could you test https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-parent-2.1.0-beta-1 ? It's a beta version, it does not appear in the update center unless you have enable the "experimental" update center. You can verify that the settings are used with " mvn help:effective-settings ". The log message indicating that Maven settings and/or Maven Global Settings are injected look like [withMaven] use Maven global settings provided by the Jenkins global configuration 'global-maven-settings' [withMaven] use Maven global settings.xml 'global-maven-settings' with Maven servers credentials provided by Jenkins (replaceAll: false): [mavenServerId: 'global-credentials-bitbucket', jenkinsCredentials: 'bitbucket-credentials', username: 'cleclerc', type: 'UsernamePasswordCredentialsImpl']
            Hide
            cleclerc Cyrille Le Clerc added a comment -

            System default (ie Jenkins "Global Tools Configuration") Maven settings and Maven Global Settings are supported in version 2.1.0.
            As there is no support for defining the default Maven version in the "Global Tools Configuration", I close this RFE.
            We could create another RFE to introduce the support of a default Maven version (ie Jenkins "Global Tools Configuration" or equivalent at the folder level).

            Show
            cleclerc Cyrille Le Clerc added a comment - System default (ie Jenkins "Global Tools Configuration") Maven settings and Maven Global Settings are supported in version 2.1.0. As there is no support for defining the default Maven version in the "Global Tools Configuration", I close this RFE. We could create another RFE to introduce the support of a default Maven version (ie Jenkins "Global Tools Configuration" or equivalent at the folder level).

              People

              Assignee:
              cleclerc Cyrille Le Clerc
              Reporter:
              twasink Robert Watkins
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: