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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      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

        Attachments

          Activity

          Hide
          gopal_ahir Gopal Ahir added a comment -

          We are also facing the same issue. Is there any update on it?

          Show
          gopal_ahir Gopal Ahir added a comment - We are also facing the same issue. Is there any update on it?
          Hide
          jglick Jesse Glick added a comment -

          Indeed the node and ws steps do not currently force creation of the workspace directory. This is not a bug; it would be a bug in some other plugin if a Step taking a FilePath context assumed that the directory existed when it started running and neglected to call mkdirs.

          Show
          jglick Jesse Glick added a comment - Indeed the node and ws steps do not currently force creation of the workspace directory. This is not a bug; it would be a bug in some other plugin if a Step taking a FilePath context assumed that the directory existed when it started running and neglected to call mkdirs .

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            szhem Sergey Zhemzhitsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: