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

Configure provided settings.xml at the Maven plugin level, not at the Maven job level

      To use global and user settings.xml provided by the Config File Provider plugin, one must declare both files to be used with every single job. This is a lot of work, hence error prone.

      It would be smarter if one could simply go to "Manage Jenkins > Configure Jenkins > Maven" and declare the provided settings.xml files to be used there.

      Benefit: The jobs do not need to know about any particular settings.xml file. All jobs run with this Maven version will then use that settings.xml files automatically. One could not accidentially forget to configure these files at new jobs.

          [JENKINS-16706] Configure provided settings.xml at the Maven plugin level, not at the Maven job level

          This sounds like a duplicate of JENKINS-17723. The latter is marked as resolved but it seems not to be working.
          I actually don't get the global Maven Configuration settings to work at all. No matter what I set as default settings providers, only the default maven settings are used, i.e. user settings from ~/.m2 and global settings from the maven installation. No override takes place:

          Executing Maven: -B -f /var/lib/jenkins/jobs/test_maven/workspace/pom.xml help:effective-settings

          Florian Zschocke added a comment - This sounds like a duplicate of JENKINS-17723 . The latter is marked as resolved but it seems not to be working. I actually don't get the global Maven Configuration settings to work at all. No matter what I set as default settings providers, only the default maven settings are used, i.e. user settings from ~/.m2 and global settings from the maven installation. No override takes place: Executing Maven: -B -f /var/lib/jenkins/jobs/test_maven/workspace/pom.xml help:effective-settings

          Anders Hammar added a comment -

          Yes, this should be closed as a dupe of JENKINS-17723. That fix works in my LTS 1.532.1 installation (at least for settings file, don't use global settings file). It gives a default configuration on the project, which can then be re-configured should it be required.

          Anders Hammar added a comment - Yes, this should be closed as a dupe of JENKINS-17723 . That fix works in my LTS 1.532.1 installation (at least for settings file, don't use global settings file). It gives a default configuration on the project, which can then be re-configured should it be required.

          Florian Zschocke added a comment - - edited

          I am trying this with 1.539 and can not get it to work at all. Not with a path to a file nor with a provided config file.
          Config File Provider plugin version 2.7.1
          Platform is Linux.

          Florian Zschocke added a comment - - edited I am trying this with 1.539 and can not get it to work at all. Not with a path to a file nor with a provided config file. Config File Provider plugin version 2.7.1 Platform is Linux.

          Markus KARG added a comment -

          I opened this issue one year ago and wanted to see how well things work.
          I have to say that with Jenkins 1.532.2 + latest config plugin THIS DOES STILL NOT WORK.
          If I do not provide any configuration inside the JOB, the MavenRedeploy (= the "Deploy to Maven Repository" post-build action) is NOT using the non-global settings.xml file configured in the config plugin. Hence, it always fails with "unauthorized" as the passwords are in that non-global file.

          I REALLY BEG YOU TO FIX THIS, AS IT IS REALLY ANNOYING!

          Markus KARG added a comment - I opened this issue one year ago and wanted to see how well things work. I have to say that with Jenkins 1.532.2 + latest config plugin THIS DOES STILL NOT WORK. If I do not provide any configuration inside the JOB, the MavenRedeploy (= the "Deploy to Maven Repository" post-build action) is NOT using the non-global settings.xml file configured in the config plugin. Hence, it always fails with "unauthorized" as the passwords are in that non-global file. I REALLY BEG YOU TO FIX THIS, AS IT IS REALLY ANNOYING!

          Markus KARG added a comment -

          Ok I am a step further now and have it running, and I think I know what the problem is.
          First of all, I confirm that "Use default maven global settings" is working very well and it effectively leads to using the configured global settings.xml provided by the Config File Provider plugin.
          Also I confirm that the option "provided settings.xml" is working well and it effectievely leads to using the configured settings.xml provided by the Config File Provider plugin – but that one has to be told in each and every Maven job description!
          What not work is "Use default maven settings". It leads to the fact that Jenkins still is using a "vanilly" Maven config instead of the settings.xml provided by the Config File Provider plugin. And it looks like this is a known "limitation" (I would say: "bug") of the plugin.

          Can someone please please please fix this?

          Markus KARG added a comment - Ok I am a step further now and have it running, and I think I know what the problem is. First of all, I confirm that "Use default maven global settings" is working very well and it effectively leads to using the configured global settings.xml provided by the Config File Provider plugin. Also I confirm that the option "provided settings.xml" is working well and it effectievely leads to using the configured settings.xml provided by the Config File Provider plugin – but that one has to be told in each and every Maven job description! What not work is "Use default maven settings". It leads to the fact that Jenkins still is using a "vanilly" Maven config instead of the settings.xml provided by the Config File Provider plugin. And it looks like this is a known "limitation" (I would say: "bug") of the plugin. Can someone please please please fix this?

          This is not a bug, the "Use default maven settings" are the "vanilla" settings.xml in the .m2 directory - so it actually works as designed

          Dominik Bartholdi added a comment - This is not a bug, the "Use default maven settings" are the "vanilla" settings.xml in the .m2 directory - so it actually works as designed

          ...so what should be the proper way to specify globally setting.xml without configuring each job manually?

          Giacomo Boccardo added a comment - ...so what should be the proper way to specify globally setting.xml without configuring each job manually?

          Anders Hammar added a comment -

          If you in the Jenkins configuration configure "Default (global) settings provider" as "provided settings.xml", that will be the default configuration for both Maven projects (build step) and freeestyle projects (Maven build step). I've just verified this for settings (not global, but I assume that will work as well) in Jenkins LTS 1.609.2 with config-file-provider-plugin 2.8.1 (and maven-project-plugin 1.6).

          Anders Hammar added a comment - If you in the Jenkins configuration configure "Default (global) settings provider" as "provided settings.xml", that will be the default configuration for both Maven projects (build step) and freeestyle projects (Maven build step). I've just verified this for settings (not global, but I assume that will work as well) in Jenkins LTS 1.609.2 with config-file-provider-plugin 2.8.1 (and maven-project-plugin 1.6).

          Anders Hammar added a comment -

          Just to be clear, this default setting can be overridden on projetc level. But for every new project it is going to be the the default configuration. However, it will not affect any existing project. Maybe that's the confusion here.

          Anders Hammar added a comment - Just to be clear, this default setting can be overridden on projetc level. But for every new project it is going to be the the default configuration. However, it will not affect any existing project. Maybe that's the confusion here.

          Markus KARG added a comment - - edited

          What I actually like to get is not an initial setting for a new job, but a facility where I can go to an existing job and say "use the config given to the Maven plugin", and have a setting at the Maven plugin which will be used then. Neither do I want a solution working only for new jobs, nor do I want to use to files found locally in the .m2 folder. I hope it is more clear now what my problem is. I have hundreds of existing jobs and all shall use one central setting independend of the client they are running on.

          Markus KARG added a comment - - edited What I actually like to get is not an initial setting for a new job, but a facility where I can go to an existing job and say "use the config given to the Maven plugin", and have a setting at the Maven plugin which will be used then. Neither do I want a solution working only for new jobs, nor do I want to use to files found locally in the .m2 folder. I hope it is more clear now what my problem is. I have hundreds of existing jobs and all shall use one central setting independend of the client they are running on.

          I hope this feature will be implemented because I can't configure manually all the existing jobs.

          Giacomo Boccardo added a comment - I hope this feature will be implemented because I can't configure manually all the existing jobs.

          bcalmac added a comment -

          So what does JENKINS-17723 fix if this problem is still there? It doesn't look like this is a duplicate. As far as I can see there's currently no way to globally specify a settings.xml to be used by all jobs.

          bcalmac added a comment - So what does JENKINS-17723 fix if this problem is still there? It doesn't look like this is a duplicate. As far as I can see there's currently no way to globally specify a settings.xml to be used by all jobs.

          bcalmac, I don't think this ticket is exactly a duplicate of the other one because, according to the title, it solves the issue only for new jobs.

          Giacomo Boccardo added a comment - bcalmac , I don't think this ticket is exactly a duplicate of the other one because, according to the title, it solves the issue only for new jobs.

          Mike Duigou added a comment -

          The maven plugin "Maven Configuration" of settings.xml seems to be entirely ignored by projects and by scripts which try to run mvn executable directly. The project level "Use default maven settings" should respect the plugin level setting.

          Mike Duigou added a comment - The maven plugin "Maven Configuration" of settings.xml seems to be entirely ignored by projects and by scripts which try to run mvn executable directly. The project level "Use default maven settings" should respect the plugin level setting.

          Nils Renaud added a comment -

          One year later, Is there any news about this feature (which could be really useful !!) ?

          Nils Renaud added a comment - One year later, Is there any news about this feature (which could be really useful !!) ?

          no, but PRs are welcome...

          Dominik Bartholdi added a comment - no, but PRs are welcome...

            domi Dominik Bartholdi
            mkarg Markus KARG
            Votes:
            9 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: