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

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

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.73.1
      Plugins:
      * Pipeline v2.5
      * Pipeline: Declarative v1.2.5
      * Pipeline: Job v2.15
    • Similar Issues:

      Description

      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

       

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              dalbertom dalbertom
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: