paths with symlinks are handled inconsistently in a pipeline job vs a freestyle job

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      In our environment, the home directory is a symlink to another location

      ln -s /vol/slavedata/home.jenkins /home/jenkins

      So the WORKSPACE environment variable in a test-pipeline job points to something like /home/jenkins/workspace/test-pipeline, and the real path would be /vol/slavedata/home.jenkins/workspace/test-pipeline

      In a FreeStyle job I have the following groovy script:

      def ws = new File(System.getenv('WORKSPACE')) // /home/jenkins/workspace/test-freestyle
      def ws2 = new File('/vol/slavedata/home.jenkins/workspace/test-freestyle')
      
      println ws.canonicalPath
      println ws2.canonicalPath
      

      and the output is as expected:

      /vol/slavedata/home.jenkins/workspace/test-freestyle
      /vol/slavedata/home.jenkins/workspace/test-freestyle

       

      However, in a Pipeline job, a similar script:

      pipeline {
        agent any
        stages {
          stage('test') {
            steps {
              script {
                def ws = new File(env.WORKSPACE) // /home/jenkins/workspace/test-pipeline
                def ws2 = new File('/vol/slavedata/home.jenkins/workspace/test-pipeline')
                echo ws.canonicalPath
                echo ws2.canonicalPath
              }
            }
          }
        }
      }

      yields an unexpected result:

      [Pipeline] echo
      /home/jenkins/workspace/test-pipeline
      [Pipeline] echo
      /vol/slavedata/home.jenkins/workspace/test-pipeline

       

            Assignee:
            Unassigned
            Reporter:
            dalbertom
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: