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

Hudson doesn't replace variable in settings.xml

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • maven-plugin
    • None
    • Hudson 1.336

      I have followed some best practice about using private repository for each M2 project.

      My first try was to put:

      <localRepository>${user.home}/repositories/${env.JOB_NAME}/repository</localRepository>
      

      in /var/lib/hudson/.m2/settings.xml

      but the build failed:

      Parsing POMs
      ERROR: Echec ? la lecture des POMs
      hudson.util.IOException2: remote file operation failed
      	at hudson.FilePath.act(FilePath.java:677)
      	at hudson.FilePath.act(FilePath.java:665)
      	at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:531)
      	at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:391)
      	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:417)
      	at hudson.model.Run.run(Run.java:1176)
      	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:304)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:123)
      Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Cannot find parent: com.mycompany:mycompany-super-pom for project: com.monclient.monprojet:monprojet:jar:1.0-SNAPSHOT for project com.monclient.monprojet:monprojet:jar:1.0-SNAPSHOT
      	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:881)
      	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:786)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2072)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:104)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:270)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:619)
      Caused by: hudson.remoting.ProxyException: org.apache.maven.project.ProjectBuildingException: Cannot find parent: com.mycompany:mycompany-super-pom for project: com.monclient.monprojet:monprojet:jar:1.0-SNAPSHOT for project com.monclient.monprojet:monprojet:jar:1.0-SNAPSHOT
      	at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1370)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:821)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:215)
      	at hudson.maven.MavenEmbedder.readProject(MavenEmbedder.java:334)
      	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:861)
      	... 11 more
      Caused by: hudson.remoting.ProxyException: org.apache.maven.project.ProjectBuildingException: POM 'com.mycompany:mycompany-super-pom' not found in repository: Unable to download the artifact from any repository
      

      After a bit of googling I found this that it may be caused by Maven not replacing ${user.home} [1].

      So I tried with a hard coded user.home:

      <localRepository>/var/lib/hudson/repositories/${env.JOB_NAME}/repository</localRepository>
      

      Now the build is working, but looking at the content of /var/lib/hudson/repositories I have 2 folders:

      • The first folder is named "${env.JOB_NAME}" (not evaluated) and contains the parent pom only
      • The second folder is named "My Job" (the actual job name) and contains all dependencies

      So it seems Hudson pom parser doesn't deal with variable in settings.xml (at least in localRepository section).

      [1] http://www.mail-archive.com/users@maven.apache.org/msg102070.html

          [JENKINS-5273] Hudson doesn't replace variable in settings.xml

          Julien HENRY added a comment -

          Note that there is an issue in Maven 2.2.1 not replacing ${user.home} variable in localRepository. This is fixed in Maven 3 alpha 6.

          But there is still an issue in hudson as it is not even replacing ${env.JOB_NAME}.

          Julien HENRY added a comment - Note that there is an issue in Maven 2.2.1 not replacing ${user.home} variable in localRepository. This is fixed in Maven 3 alpha 6. But there is still an issue in hudson as it is not even replacing ${env.JOB_NAME}.

          Olivier Lamy added a comment -

          And option for maven build called "Use private Maven repository" ??

          Olivier Lamy added a comment - And option for maven build called "Use private Maven repository" ??

          Julien HENRY added a comment -

          I know this option, but it has two drawbacks:

          1) I have to define it on each project
          2) The private repository is located in each job folder, and I would like to put all private repositories in the same folder (possibly on another file system).

          Read http://batmat.net/blog/post/2009/10/09/%5BHudson%5D-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them?pub=1#pr
          for more details.

          Julien HENRY added a comment - I know this option, but it has two drawbacks: 1) I have to define it on each project 2) The private repository is located in each job folder, and I would like to put all private repositories in the same folder (possibly on another file system). Read http://batmat.net/blog/post/2009/10/09/%5BHudson%5D-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them?pub=1#pr for more details.

          Hudson uses embedded Maven to parse settings.xml, so I'm bit puzzled about the inconsistency here.

          Is the variable expansion in settings.xml a recent Maven feature?

          Kohsuke Kawaguchi added a comment - Hudson uses embedded Maven to parse settings.xml, so I'm bit puzzled about the inconsistency here. Is the variable expansion in settings.xml a recent Maven feature?

          Julien HENRY added a comment -

          I don't think this is a new feature but as I said there is an issue in Maven 2.2.1 with "java properties" like ${java.home} or ${user.home} in settings.xml.

          BTW ${env.JOB_NAME} is correctly replaced during Maven build, but not during initial Hudson POM parsing.

          Julien HENRY added a comment - I don't think this is a new feature but as I said there is an issue in Maven 2.2.1 with "java properties" like ${java.home} or ${user.home} in settings.xml. BTW ${env.JOB_NAME} is correctly replaced during Maven build, but not during initial Hudson POM parsing.

          Andrew Bayer added a comment -

          I think the issue is that the JOB_NAME environment variable isn't actually set in the process that calls the embedded Maven for POM parsing - it's set in the forked Maven that gets called for the actual build, but not until then. I'm not sure how we'd get the environment variables into the process that does the parsing.

          Andrew Bayer added a comment - I think the issue is that the JOB_NAME environment variable isn't actually set in the process that calls the embedded Maven for POM parsing - it's set in the forked Maven that gets called for the actual build, but not until then. I'm not sure how we'd get the environment variables into the process that does the parsing.

          Hi all,

          Since I was having the same problem Julien filed here (my blog : http://batmat.net/blog/post/2009/10/09/[Hudson]-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them).

          I just did a bit of testing, deleting every repositories and triggering a new build while watching repositories creations. I come to the same conclusion as Andrew's.

          There are actually two phases (only for native maven builds) :
          1) The Maven Agent is launched, with something like the following command:

           
          $ java -cp /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.365.jar:/ic/logiciels/maven/boot/classworlds-1.1.jar hudson.maven.agent.Main /ic/logiciels/maven /ic/logiciels/glassfish/domains/domain1/applications/j2ee-modules/hudson-1.365/WEB-INF/lib/remoting-1.365.jar /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.365.jar 38073 /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven2.1-interceptor-1.2.jar
          

          2) Then, it displays:

          Executing Maven:  -B -f /ic/.hudson/jobs/somejob/workspace/somemvnproject/pom.xml [...]

          The second part gets variables correctly set. Only the first part triggers the ${env.JOB_NAME} directory creation.

          So for me, in fact, it doesn't seem related to pom parsing, but to a more general issue, as said above.

          Hope this helps.
          Cheers

          Baptiste Mathus added a comment - Hi all, Since I was having the same problem Julien filed here (my blog : http://batmat.net/blog/post/2009/10/09/[Hudson]-How-to-set-a-private-maven-repository-by-job-and-easily-be-able-to-delete-them ). I just did a bit of testing, deleting every repositories and triggering a new build while watching repositories creations. I come to the same conclusion as Andrew's. There are actually two phases (only for native maven builds) : 1) The Maven Agent is launched, with something like the following command: $ java -cp /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.365.jar:/ic/logiciels/maven/boot/classworlds-1.1.jar hudson.maven.agent.Main /ic/logiciels/maven /ic/logiciels/glassfish/domains/domain1/applications/j2ee-modules/hudson-1.365/WEB-INF/lib/remoting-1.365.jar /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.365.jar 38073 /ic/.hudson/plugins/maven-plugin/WEB-INF/lib/maven2.1-interceptor-1.2.jar 2) Then, it displays: Executing Maven: -B -f /ic/.hudson/jobs/somejob/workspace/somemvnproject/pom.xml [...] The second part gets variables correctly set. Only the first part triggers the ${env.JOB_NAME} directory creation. So for me, in fact, it doesn't seem related to pom parsing, but to a more general issue, as said above. Hope this helps. Cheers

          Andrew Bayer added a comment -

          This is not something we can change in the existing POM parsing logic, sadly - but hopefully we'll do a rewrite of that in the non-distant future.

          Andrew Bayer added a comment - This is not something we can change in the existing POM parsing logic, sadly - but hopefully we'll do a rewrite of that in the non-distant future.

          Jason Stiefel added a comment -

          Can we leave this open until the re-write?

          Jason Stiefel added a comment - Can we leave this open until the re-write?

          martinro added a comment -

          Same issue, but only now after updating from V1.391 to V1.397. Previously, everything worked fine.
          We are not using relative pathes.

          Found mavenVersion 2.2.1 from file jar:file:/C:/ProgrammeDE/Java/tools/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties
          Parsing POMs
          ERROR: Failed to parse POMs
          org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
          [FATAL] Non-resolvable parent POM: Could not find artifact 0000-999:STD_Project:pom:1.0.7 and 'parent.relativePath' points at wrong local POM @ line 12, column 10
          
          	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:325)
          	at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:360)
          	at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:330)
          	at hudson.maven.MavenEmbedder.readProject(MavenEmbedder.java:321)
          	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1154)
          	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:991)
          	at hudson.FilePath.act(FilePath.java:756)
          	at hudson.FilePath.act(FilePath.java:738)
          	at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:698)
          	at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:531)
          	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:420)
          	at hudson.model.Run.run(Run.java:1362)
          	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405)
          	at hudson.model.ResourceController.execute(ResourceController.java:88)
          	at hudson.model.Executor.run(Executor.java:145)
          

          martinro added a comment - Same issue, but only now after updating from V1.391 to V1.397. Previously, everything worked fine. We are not using relative pathes. Found mavenVersion 2.2.1 from file jar:file:/C:/ProgrammeDE/Java/tools/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties Parsing POMs ERROR: Failed to parse POMs org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM: Could not find artifact 0000-999:STD_Project:pom:1.0.7 and 'parent.relativePath' points at wrong local POM @ line 12, column 10 at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:325) at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:360) at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:330) at hudson.maven.MavenEmbedder.readProject(MavenEmbedder.java:321) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1154) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:991) at hudson.FilePath.act(FilePath.java:756) at hudson.FilePath.act(FilePath.java:738) at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:698) at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:531) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:420) at hudson.model.Run.run(Run.java:1362) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:145)

            Unassigned Unassigned
            henryju Julien HENRY
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: