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

Setting "mavenLocalRepo" to ".repository" creates a "$WORKSPACE/?/.m2/repository" folder

      abayer reports that setting "mavenLocalRepo" to ".repository" creates a "$WORKSPACE/?/.m2/repository" folder.

      https://github.com/jenkinsci/docker-workflow-plugin/pull/97#issuecomment-341566106

      It seems to be with docker-workflow-plugin 1.14.

      I can't reproduce on a Mac.

          [JENKINS-47804] Setting "mavenLocalRepo" to ".repository" creates a "$WORKSPACE/?/.m2/repository" folder

          Cyrille Le Clerc added a comment - - edited

          abayer can you please give more details on the case in which you get this problem?

          Cyrille Le Clerc added a comment - - edited abayer can you please give more details on the case in which you get this problem?

          Cyrille Le Clerc added a comment - context.get(FilePath.class) + envOverride.expand(env.expand(step.getMavenLocalRepo())) https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.2/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java#L144 https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.2/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java#L573

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/0cc6d3f58b2b9d41a12b39997d4f90cfad8b7dd3
          Log:
          JENKINS-47804 add troubleshooting log messages

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java http://jenkins-ci.org/commit/pipeline-maven-plugin/0cc6d3f58b2b9d41a12b39997d4f90cfad8b7dd3 Log: JENKINS-47804 add troubleshooting log messages

          Jan Zuchhold added a comment -

          The problem is that the maven wrapper script does not get executed anymore since the fix for JENKINS-40484 was applied. This is because the PATH variable does not get forwarded to the docker container anymore.

          Jenkinsfile
          // This works with docker-workflow=1.13 and fails with docker-workflow=1.14
          node {
              stage("JENKINS-47804") {
                  docker.image("maven:latest").inside {
                      withMaven(mavenLocalRepo: 'myrepo') {
                          String output = sh(script:"mvn help:effective-settings | grep localRepository", returnStdout: true)
                          println "Repo: ${output}"
                          assert output.contains("myrepo")
                      }
                  }
              }
          }
          

          Jan Zuchhold added a comment - The problem is that the maven wrapper script does not get executed anymore since the fix for JENKINS-40484 was applied. This is because the PATH variable does not get forwarded to the docker container anymore. Jenkinsfile // This works with docker-workflow=1.13 and fails with docker-workflow=1.14 node { stage( "JENKINS-47804" ) { docker.image( "maven:latest" ).inside { withMaven(mavenLocalRepo: 'myrepo' ) { String output = sh(script: "mvn help:effective-settings | grep localRepository" , returnStdout: true ) println "Repo: ${output}" assert output.contains( "myrepo" ) } } } }

          Andrew Bayer added a comment -

          Yeah, that example reproduces for me on Ubuntu or CentOS. We had to remove PATH from the env passed into the container due to other bugs, and it makes sense in general, since the PATH on the agent isn’t going to be applicable in the container. So this seems to be an issue in Pipeline Maven...

          Andrew Bayer added a comment - Yeah, that example reproduces for me on Ubuntu or CentOS. We had to remove PATH from the env passed into the container due to other bugs, and it makes sense in general, since the PATH on the agent isn’t going to be applicable in the container. So this seems to be an issue in Pipeline Maven...

          Cyrille Le Clerc added a comment - - edited

          Thanks abayer.

          > We had to remove PATH from the env passed into the container due to other bugs, and it makes sense in general, since the PATH on the agent isn’t going to be applicable in the container. So this seems to be an issue in Pipeline Maven...

          Ack. I am updating withMaven to provide a lovable experience in Docker Pipeline when "PATH" don't get updated:

          > Yeah, that example reproduces for me on Ubuntu or CentOS.

          I think I have seen such issues in the past with Docker containers running as root. From what I remember, the fact that the user is "root" can create issues in many places. I'll try my best to have a look soon.

          Note that I have been interested in providing a higher level of abstraction for the Maven local repository location and

          • Mimic the Maven Job Type "Use Private Maven Repository" (screenshot below)
          • Work on local repository caching, even in the context of dockerized build agents

           

          Cyrille Le Clerc added a comment - - edited Thanks abayer . > We had to remove PATH from the env passed into the container due to other bugs, and it makes sense in general, since the PATH on the agent isn’t going to be applicable in the container. So this seems to be an issue in Pipeline Maven... Ack. I am updating withMaven to provide a lovable experience in Docker Pipeline when "PATH" don't get updated: JENKINS-47823 withMaven fails to inject Maven settings files with docker-pipeline 1.14 https://github.com/jenkinsci/pipeline-maven-plugin/pull/108 > Yeah, that example reproduces for me on Ubuntu or CentOS. I think I have seen such issues in the past with Docker containers running as root. From what I remember, the fact that the user is "root" can create issues in many places. I'll try my best to have a look soon. Note that I have been interested in providing a higher level of abstraction for the Maven local repository location and Mimic the Maven Job Type "Use Private Maven Repository" (screenshot below) Work on local repository caching, even in the context of dockerized build agents  

          > This is because the PATH variable does not get forwarded to the docker container anymore.

          jan_z please follow the issue JENKINS-47823 withMaven fails to inject Maven settings files with docker-pipeline 1.14

          Cyrille Le Clerc added a comment - > This is because the PATH variable does not get forwarded to the docker container anymore. jan_z please follow the issue JENKINS-47823 withMaven fails to inject Maven settings files with docker-pipeline 1.14

            cleclerc Cyrille Le Clerc
            cleclerc Cyrille Le Clerc
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: