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

withMaven is not picking global configuration defined under tools

      It seems that "withMaven" is not picking global configuration correctly when maven is defined under "tools" although logs indicate it otherwise. 

      Here is sample pipeline:

      pipeline {
          agent any
          tools {
              maven 'maven3'       //1
              jdk 'openjdk-11'
          }
          stages {
              stage('Not Ok') { 
                  steps {
                  	withMaven{       //2
              	    sh "mvn help:effective-settings"
              	}
                  }
              }
              stage('Ok') { 
                  steps {
                  	withMaven(maven: 'maven3'){        //3
              	    sh "mvn help:effective-settings"
              	}
                  }
              }
          }
      }
      

       

      I have defined my Global Settings settings.xml (under Managed Files) and it's configured under Global Tool Configuration.

      When you run the pipeline then at (2) in logs this can be found:

      [withMaven] using Maven global settings.xml '4a3dd40e-13fa-4d56-9a7d-6c2390e85aa2'  

      but maven effective settings does not print my settings.xml.

       

      However, when I explicitely define maven with (3)

      withMaven(maven: 'maven3')

      then effective settings include my settings.xml.

      Please check attached file.

      I would expect that it is enough do define maven once (1) to pick correct settings.xml.

       
       
       

          [JENKINS-68235] withMaven is not picking global configuration defined under tools

          Mariusz Ćwikła created issue -
          Mariusz Ćwikła made changes -
          Summary Original: withMaven is not picking global configuration deffined under tools New: withMaven is not picking global configuration defined under tools
          Mariusz Ćwikła made changes -
          Description Original: It seems that "withMaven" is not picking global configuration correctly when maven is defined under "tools" although logs indicate it otherwise. 


           Here is sample pipeline:
          {code:groovy}
          pipeline {
              agent any
          tools {
          maven 'maven3' //1
          jdk 'openjdk-11'
          }
              stages {
                  stage('Not Ok') {
                      steps {
                       withMaven{ //2
                   sh "mvn help:effective-settings"
                   }
                      }
                  }
                  stage('Ok') {
                      steps {
                       withMaven(maven: 'maven3'){ //3
                   sh "mvn help:effective-settings"
                   }
                      }
                  }
              }
          }
          {code}
           

          I have defined my Global Settings settings.xml (under Managed Files) and it's configured under Global Tool Configuration.


          When you run the pipeline then at (2) in logs this can be found:
          {code:java}
          [withMaven] using Maven global settings.xml '4a3dd40e-13fa-4d56-9a7d-6c2390e85aa2' {code}
          but maven effective settings does not print my settings.xml.

           

          However, when I explicitely define maven with (3)
          {noformat}
          withMaven(maven: 'maven3'){noformat}
          then effective settings include my settings.xml.

          Please check attached file.

          I would expect that it is enough do define maven once (1) to pick correct settings.xml.

           
           
           
          New: It seems that "withMaven" is not picking global configuration correctly when maven is defined under "tools" although logs indicate it otherwise. 

          Here is sample pipeline:
          {code:groovy}
          pipeline {
              agent any
              tools {
                  maven 'maven3' //1
                  jdk 'openjdk-11'
              }
              stages {
                  stage('Not Ok') {
                      steps {
                       withMaven{ //2
                   sh "mvn help:effective-settings"
                   }
                      }
                  }
                  stage('Ok') {
                      steps {
                       withMaven(maven: 'maven3'){ //3
                   sh "mvn help:effective-settings"
                   }
                      }
                  }
              }
          }
          {code}
           

          I have defined my Global Settings settings.xml (under Managed Files) and it's configured under Global Tool Configuration.

          When you run the pipeline then at (2) in logs this can be found:
          {code:java}
          [withMaven] using Maven global settings.xml '4a3dd40e-13fa-4d56-9a7d-6c2390e85aa2' {code}
          but maven effective settings does not print my settings.xml.

           

          However, when I explicitely define maven with (3)
          {noformat}
          withMaven(maven: 'maven3'){noformat}
          then effective settings include my settings.xml.

          Please check attached file.

          I would expect that it is enough do define maven once (1) to pick correct settings.xml.

           
            
            
          Benoit made changes -
          Link New: This issue is duplicated by JENKINS-59567 [ JENKINS-59567 ]
          Benoit made changes -
          Link New: This issue is duplicated by JENKINS-50662 [ JENKINS-50662 ]

            Unassigned Unassigned
            mcwikal Mariusz Ćwikła
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: