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

"IllegalArgumentException : Cannot relativize '...' relatively to ...'" with symlinks

      Having jenkins installed in /app/Jenkins/home and /var/lib/jenkins symlinked to it results with this pipeline

      node {
          withMaven(maven: 'maven-3.3.9') {
              sh "mvn clean install"
          }
      }

      in this error

      ERROR: [withMaven] WARNING: Exception archiving and fingerprinting MavenArtifact{parent:pom:0.0.1-SNAPSHOT /app/Jenkins/home/workspace/testjob/pom.xml}, skip archiving of the artifacts
      java.lang.IllegalArgumentException: Cannot relativize '/app/Jenkins/home/workspace/testjob/pom.xml' relatively to '/var/lib/jenkins/workspace/testjob'
      at org.jenkinsci.plugins.pipeline.maven.util.XmlUtils.getPathInWorkspace(XmlUtils.java:226)
      at org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher.process(GeneratedArtifactsPublisher.java:80)
      at org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor.processMavenSpyLogs(MavenSpyLogProcessor.java:109)
      at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution$Callback.finished(WithMavenStepExecution.java:864)
      at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:114)
      at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:362)
      at com.cloudbees.groovy.cps.Outcome.resumeFrom(Outcome.java:73)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:165)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
      at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
      at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)

      This issue might be related to https://issues.jenkins-ci.org/browse/JENKINS-44359

          [JENKINS-46084] "IllegalArgumentException : Cannot relativize '...' relatively to ...'" with symlinks

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtils.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtilsTest.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/76cdc728f341b3e28a4a09a624dd36eef049387f
          Log:
          JENKINS-46084 workaround symlinks handling on the path of the workspace

          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/util/XmlUtils.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtilsTest.java http://jenkins-ci.org/commit/pipeline-maven-plugin/76cdc728f341b3e28a4a09a624dd36eef049387f Log: JENKINS-46084 workaround symlinks handling on the path of the workspace

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtils.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtilsTest.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/1f867a959b1f9bb06434272fe55c372e27c1ac0a
          Log:
          Merge pull request #77 from jenkinsci/JENKINS-46084

          JENKINS-46084 workaround symlinks handling on the path of the works…

          Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/9058b84a0c42...1f867a959b1f

          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/util/XmlUtils.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtilsTest.java http://jenkins-ci.org/commit/pipeline-maven-plugin/1f867a959b1f9bb06434272fe55c372e27c1ac0a Log: Merge pull request #77 from jenkinsci/ JENKINS-46084 JENKINS-46084 workaround symlinks handling on the path of the works… Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/9058b84a0c42...1f867a959b1f

          Cyrille Le Clerc added a comment - - edited

          Fixed in 3.0.0-beta

           

          elexx can you please verify that 3.0.0-beta-4 fixes your symlink problem? https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-3.0.0-beta-4 ?

          Cyrille Le Clerc added a comment - - edited Fixed in 3.0.0-beta   elexx can you please verify that 3.0.0-beta-4 fixes your symlink problem?  https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-3.0.0-beta-4  ?

          cleclerc, I just tested the 3.0.0-beta-4 and it works as expected! Thanks for the quick fix!

          Alexander Falb added a comment - cleclerc , I just tested the 3.0.0-beta-4 and it works as expected! Thanks for the quick fix!

          Thanks elexx!

          Cyrille Le Clerc added a comment - Thanks elexx !

          Liad Shani added a comment -

          Unfortunately, 3.0.0-beta-4 doesn't fix the issue in my case.

          My Jenkins was installed many years ago, before the default location for the workspace folder changed. In my setup, the workspace folder is last in the path, without a trailing delimiter. I guess that's why the fix didn't work for me.

          Also, since the workspace root directory can be modified in Jenkins configuration, I think hardcoding "workspace" in code can cause problems for some (it can be renamed). Wouldn't it be better to use the Jenkins setting instead?

          Following is my exception:

          ERROR: [withMaven] artifactsPublisher - WARNING: Exception archiving and fingerprinting MavenArtifact{com.test:test-parent:pom:1.0-SNAPSHOT(version: 1.0-SNAPSHOT, snapshot:false)  /storage/jenkins/jobs/Test-Pipeline/workspace/pom.xml}, skip archiving of the artifacts
          java.lang.IllegalArgumentException: Cannot relativize '/storage/jenkins/jobs/Test-Pipeline/workspace/pom.xml' relatively to '/var/lib/jenkins/jobs/Test-Pipeline/workspace'
              at org.jenkinsci.plugins.pipeline.maven.util.XmlUtils.getPathInWorkspace(XmlUtils.java:244)
              at org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher.process(GeneratedArtifactsPublisher.java:80)
              at org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor.processMavenSpyLogs(MavenSpyLogProcessor.java:110)
              at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution$Callback.finished(WithMavenStepExecution.java:870)
              at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:114)
              at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:362)
              at com.cloudbees.groovy.cps.impl.ForLoopBlock$ContinuationImpl.loopCond(ForLoopBlock.java:50)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
              at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:60)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
              at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
              at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:60)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:77)
              at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
              at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
              at com.cloudbees.groovy.cps.Next.step(Next.java:83)
              at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)
              at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
              at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
              at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
              at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)
              at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
              at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
              at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
              at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
              at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
              at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
              at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
              at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at java.lang.Thread.run(Thread.java:748)
          

          Liad Shani added a comment - Unfortunately, 3.0.0-beta-4 doesn't fix the issue in my case. My Jenkins was installed many years ago, before the default location for the workspace folder changed. In my setup, the workspace folder is last in the path, without a trailing delimiter. I guess that's why the fix didn't work for me. Also, since the workspace root directory can be modified in Jenkins configuration, I think hardcoding "workspace" in code can cause problems for some (it can be renamed). Wouldn't it be better to use the Jenkins setting instead? Following is my exception: ERROR: [withMaven] artifactsPublisher - WARNING: Exception archiving and fingerprinting MavenArtifact{com.test:test-parent:pom:1.0-SNAPSHOT(version: 1.0-SNAPSHOT, snapshot: false )  /storage/jenkins/jobs/Test-Pipeline/workspace/pom.xml}, skip archiving of the artifacts java.lang.IllegalArgumentException: Cannot relativize '/storage/jenkins/jobs/Test-Pipeline/workspace/pom.xml' relatively to '/ var /lib/jenkins/jobs/Test-Pipeline/workspace'     at org.jenkinsci.plugins.pipeline.maven.util.XmlUtils.getPathInWorkspace(XmlUtils.java:244)     at org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher.process(GeneratedArtifactsPublisher.java:80)     at org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor.processMavenSpyLogs(MavenSpyLogProcessor.java:110)     at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution$Callback.finished(WithMavenStepExecution.java:870)     at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:114)     at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:362)     at com.cloudbees.groovy.cps.impl.ForLoopBlock$ContinuationImpl.loopCond(ForLoopBlock.java:50)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)     at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:60)     at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)     at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)     at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)     at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:60)     at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)     at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:77)     at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)     at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)     at com.cloudbees.groovy.cps.Next.step(Next.java:83)     at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)     at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)     at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)     at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)     at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)     at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)     at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)     at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)     at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)     at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)     at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)     at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)     at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)     at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)     at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)     at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)     at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)     at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)     at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)     at java.lang. Thread .run( Thread .java:748)

          > ... In my setup, the workspace folder is last in the path, without a trailing delimiter. I guess that's why the fix didn't work for me.

          You are right, I am searching for "/workspace/"

          > Also, since the workspace root directory can be modified in Jenkins configuration, I think hardcoding "workspace" in code can cause problems for some (it can be renamed).

          agreed, it's a workaround. See below

          > Wouldn't it be better to use the Jenkins setting instead?

          Unfortunately the Maven process is not aware that Jenkins is using a symbolically linked path for the workspace. I would like to replace the Jenkins workspace path by its canonical path as commented here but this is not a trivial task. I want to first ship the downstream pipeline trigger that has been "in progress" for a while.

          Maybe, waiting for the clean fix, we can make the workaround a bit smarter.

           

           

          Cyrille Le Clerc added a comment - > ... In my setup, the workspace folder is last in the path, without a trailing delimiter. I guess that's why the fix didn't work for me. You are right, I am searching for "/workspace/" > Also, since the workspace root directory can be modified in Jenkins configuration, I think hardcoding "workspace" in code can cause problems for some (it can be renamed). agreed, it's a workaround. See below > Wouldn't it be better to use the Jenkins setting instead? Unfortunately the Maven process is not aware that Jenkins is using a symbolically linked path for the workspace. I would like to replace the Jenkins workspace path by its canonical path as commented  here  but this is not a trivial task. I want to first ship the downstream pipeline trigger that has been "in progress" for a while. Maybe, waiting for the clean fix, we can make the workaround a bit smarter.    

          Cyrille Le Clerc added a comment - liad can you please test https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-3.0.0-beta-6  , it should fix your problem. Testcase:  https://github.com/jenkinsci/pipeline-maven-plugin/commit/6a58dfab773e7e3275bf4cce368ebb8cafa20dc3#diff-2af4d0693a4216dec288765cedc323f0R202

          Liad Shani added a comment -

          Thanks cleclerc !
          It's working properly now.

          I missed that TODO comment

          Liad Shani added a comment - Thanks cleclerc ! It's working properly now. I missed that TODO comment

          Fixed in 3.0.0

          Cyrille Le Clerc added a comment - Fixed in 3.0.0

            cleclerc Cyrille Le Clerc
            elexx Alexander Falb
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: