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

Jenkins does not allocate workspace for neither declarative pipeline nor scripted pipeline jobs

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Not A Defect
    • Icon: Minor Minor

      Pipeline jobs do not allocate workspace automatically

      Steps to reproduce for scripted pipeline

      1. Create pipeline job
      2. Put the following script into "Pipeline Script" field
      node {
         stage('Prepare') {
              echo "WS: ${pwd()}, EXISTS: ${new File(pwd()).exists()}"
              echo "WS_TMP: ${pwd(tmp: true)}, EXISTS: ${new File(pwd(tmp: true)).exists()}"
              echo "CWD: ${new File('.').absolutePath}"
              echo "USER_DIR: ${System.getProperty('user.dir')}"
         }
      } 
      1. Uncheck "Use Groovy Sandbox" 
      2. Run the job

      Expected result: workspace directory exists

      Actual result: workspace directory does not exist

      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] node
      Running on Jenkins in /var/lib/jenkins/jobs/automation/jobs/test2/workspace
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Prepare)
      [Pipeline] pwd
      [Pipeline] pwd
      [Pipeline] echo
      WS: /var/lib/jenkins/jobs/automation/jobs/test2/workspace, EXISTS: false
      [Pipeline] pwd
      [Pipeline] pwd
      [Pipeline] echo
      WS_TMP: /var/lib/jenkins/jobs/automation/jobs/test2/workspace@tmp, EXISTS: false
      [Pipeline] echo
      CWD: /.
      [Pipeline] echo
      USER_DIR: /
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS 

       

      Steps to reproduce for declarative pipeline

      1. Create pipeline job
      2. Put the following script into "Pipeline Script" field
       pipeline {
          agent any
          stages {
              stage ('Prepare') {
                  steps {
                      echo "WS: ${pwd()}, EXISTS: ${new File(pwd()).exists()}"
                      echo "WS_TMP: ${pwd(tmp: true)}, EXISTS: ${new File(pwd(tmp: true)).exists()}"
                      echo "CWD: ${new File('.').absolutePath}"
                      echo "USER_DIR: ${System.getProperty('user.dir')}"
                  }
              }
          }
      }
      1. Uncheck "Use Groovy Sandbox" 
      2. Run the job

      Expected result: workspace directory exists

      Actual result: workspace directory does not exist

       Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] node
      Running on Jenkins in /var/lib/jenkins/jobs/automation/jobs/test/workspace
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Prepare)
      [Pipeline] pwd
      [Pipeline] pwd
      [Pipeline] echo
      WS: /var/lib/jenkins/jobs/automation/jobs/test/workspace, EXISTS: false
      [Pipeline] pwd
      [Pipeline] pwd
      [Pipeline] echo
      WS_TMP: /var/lib/jenkins/jobs/automation/jobs/test/workspace@tmp, EXISTS: false
      [Pipeline] echo
      CWD: /.
      [Pipeline] echo
      USER_DIR: /
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

            Unassigned Unassigned
            szhem Sergey Zhemzhitsky
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: