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 .
          Hide
          icycler1 john added a comment -

          It seems that the ansible plugin does not force the workspace creation. 

          i found that pipelines would fail with the error "unable to create workspace if ansiblePlaybook was the first stage. 
          If i ran my first stage as 
          stage('write') {
          steps {
          script

          { def date = new Date() def data = "Hello World\nSecond line\n" + date writeFile(file: 'zorg.txt', text: data) sh "ls -l" }

          }
          }
          Then ran the rest of the pipeline. the workspace was created fine. 

          Show
          icycler1 john added a comment - It seems that the ansible plugin does not force the workspace creation.  i found that pipelines would fail with the error "unable to create workspace if ansiblePlaybook was the first stage.  If i ran my first stage as  stage('write') { steps { script { def date = new Date() def data = "Hello World\nSecond line\n" + date writeFile(file: 'zorg.txt', text: data) sh "ls -l" } } } Then ran the rest of the pipeline. the workspace was created fine. 

            People

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

              Dates

              Created:
              Updated: