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

withMaven is not picking global configuration defined under tools

XMLWordPrintable

      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.

       
       
       

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

              Created:
              Updated: