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

Error running maven with settings file when running multibranch pipeline with a slash in the branch

      I configured a maven settings and global settings file in the Pipeline Maven Configuration of the folder containing the multibranch pipeline job.  When I run the following stage from my Jenkins file:

      stage('Package') { 
       steps {
        withMaven()  { 
         bat "mvn clean package"
        }
       }
      }
      
      

      I get this error:

      [ERROR] Error executing Maven. [ERROR] The specified user settings file does not exist: C:\jenkins\dctl\branchespackageFspring-boot\workspace@tmp\withMaven22e2d518\settings.xml

      The reason I get this error is that the folder containing the branch is called branches%2Fspring-boot and the config file provider is replacing %2 with package (I assume this is because package is the second argument to the script that is invoked)

          [JENKINS-57324] Error running maven with settings file when running multibranch pipeline with a slash in the branch

          Mario Jauvin added a comment - - edited

          For all intents and purpose you can ignore them. I removed them as they are not important to reproducing the problem.

          Mario Jauvin added a comment - - edited For all intents and purpose you can ignore them. I removed them as they are not important to reproducing the problem.

          Mario Jauvin added a comment -

          I reformatted the description was the quote was garbling the text.  Sorry.  Any idea on whether a fix could be found?

          Mario Jauvin added a comment - I reformatted the description was the quote was garbling the text.  Sorry.  Any idea on whether a fix could be found?

          cleclerc do you have any idea what could be causing this? If this is really caused by the config-file-provider, then I would suspect it here https://github.com/jenkinsci/config-file-provider-plugin/blob/master/src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java#L95-L101 - but to be hownest I have no idea why this should be the case and I have no way to test on windows...

          Dominik Bartholdi added a comment - cleclerc do you have any idea what could be causing this? If this is really caused by the config-file-provider, then I would suspect it here  https://github.com/jenkinsci/config-file-provider-plugin/blob/master/src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java#L95-L101  - but to be hownest I have no idea why this should be the case and I have no way to test on windows...

          Mario Jauvin added a comment -

          domi I can help troubleshoot this if you want.  I have a question.  How does config file plugin provide the maven command line option (-s for settings file) to the maven command?

          I suspect that the problem may be in the pipeline-maven-plugin where in windows the % is not properly escaped when invoking the maven command.

          Mario Jauvin added a comment - domi I can help troubleshoot this if you want.  I have a question.  How does config file plugin provide the maven command line option (-s for settings file) to the maven command? I suspect that the problem may be in the pipeline-maven-plugin where in windows the % is not properly escaped when invoking the maven command.

          Cyrille Le Clerc added a comment - - edited

          marioja could you please enable the Jenkins logs on the logger "org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution2" to "FINER" and re run the build please?
          Troubleshooting message will be added in the console of your build.

          Reference: https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.6.12/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution2.java#L684

          domi I'm assigning the ticket to me

          Cyrille Le Clerc added a comment - - edited marioja could you please enable the Jenkins logs on the logger "org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution2" to "FINER" and re run the build please? Troubleshooting message will be added in the console of your build. Reference: https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.6.12/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution2.java#L684 domi I'm assigning the ticket to me

          Mario Jauvin added a comment - - edited

          I did and the problem is that when the with maven wrapper script is created, the pathnames contain %2F which when invoked inside the wrapper scripts get evaluated as arguments.  Here is the log output from WithMavenStepExecution2:

           

          Generated Maven wrapper script: 
          @echo off
          echo ----- withMaven Wrapper script -----
          "C:\APPS\apache-maven-3.6.0\bin\mvn.cmd" --batch-mode --show-version --settings "e:\cc-build\checkout\abc\citest\branches%2Ftest\workspace@tmp\withMaven94865076\settings.xml" --global-settings "e:\cc-build\checkout\abc\citest\branches%2Ftest\workspace@tmp\withMaven94865076\globalSettings.xml"  %*
          

          when calling maven in that manner, it will not work.  The generated wrapper script should double the % signs in each path argument.  For example:

           

           

          @echo off
          echo ----- withMaven Wrapper script -----
          "C:\APPS\apache-maven-3.6.0\bin\mvn.cmd" --batch-mode --show-version --settings "e:\cc-build\checkout\aws\citest\branches%%2Ftest\workspace@tmp\withMaven94865076\settings.xml" --global-settings "e:\cc-build\checkout\aws\citest\branches%%2Ftest\workspace@tmp\withMaven94865076\globalSettings.xml"  %*
          

           I tested modifying the withMaven wrapper script manually and it works.

          Mario Jauvin added a comment - - edited I did and the problem is that when the with maven wrapper script is created, the pathnames contain %2F which when invoked inside the wrapper scripts get evaluated as arguments.  Here is the log output from WithMavenStepExecution2:   Generated Maven wrapper script: @echo off echo ----- withMaven Wrapper script ----- "C:\APPS\apache-maven-3.6.0\bin\mvn.cmd" --batch-mode --show-version --settings "e:\cc-build\checkout\abc\citest\branches%2Ftest\workspace@tmp\withMaven94865076\settings.xml" --global-settings "e:\cc-build\checkout\abc\citest\branches%2Ftest\workspace@tmp\withMaven94865076\globalSettings.xml"  %* when calling maven in that manner, it will not work.  The generated wrapper script should double the % signs in each path argument.  For example:     @echo off echo ----- withMaven Wrapper script ----- "C:\APPS\apache-maven-3.6.0\bin\mvn.cmd" --batch-mode --show-version --settings "e:\cc-build\checkout\aws\citest\branches%%2Ftest\workspace@tmp\withMaven94865076\settings.xml" --global-settings "e:\cc-build\checkout\aws\citest\branches%%2Ftest\workspace@tmp\withMaven94865076\globalSettings.xml"  %*  I tested modifying the withMaven wrapper script manually and it works.

          Mario Jauvin added a comment -

          From what I understand the code, the method setupMaven which defines and overrides the MAVEN_CONFIG environment variable is not Windows specific so that making the change in that method would require knowing the platform.

          Mario Jauvin added a comment - From what I understand the code, the method setupMaven which defines and overrides the MAVEN_CONFIG environment variable is not Windows specific so that making the change in that method would require knowing the platform.

          Cyrille Le Clerc added a comment - Fix in progress https://github.com/jenkinsci/pipeline-maven-plugin/pull/211

          Mario Jauvin added a comment -

          Did you have a chance to look at my suggested fix?

          Mario Jauvin added a comment - Did you have a chance to look at my suggested fix?

          fixed in 3.6.13

          Cyrille Le Clerc added a comment - fixed in 3.6.13

            cleclerc Cyrille Le Clerc
            marioja Mario Jauvin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: