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

    Details

    • Similar Issues:

      Description

      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)

        Attachments

          Activity

          Hide
          marioja 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.

          Show
          marioja 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.
          Hide
          marioja 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.

          Show
          marioja 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.
          Show
          cleclerc Cyrille Le Clerc added a comment - Fix in progress https://github.com/jenkinsci/pipeline-maven-plugin/pull/211
          Hide
          marioja Mario Jauvin added a comment -

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

          Show
          marioja Mario Jauvin added a comment - Did you have a chance to look at my suggested fix?
          Hide
          cleclerc Cyrille Le Clerc added a comment -

          fixed in 3.6.13

          Show
          cleclerc Cyrille Le Clerc added a comment - fixed in 3.6.13

            People

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

              Dates

              • Created:
                Updated:
                Resolved: