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

Job directory is empty when using pipeline multi-branch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      We have a multi-branch pipeline setup with our repo in GitHub. Since yesterday, we started noticing that new branches created in GitHub were not passing the build because, of the three directories that get created for the build, the @script dir has the sources, the @tmp is also present but the actual workspace directory is just empty. So, in our case,

      DebugTool-SomeRandomNum directory is just empty
      DebugTool-SomeRandomNum@script dirctory has the sources

      This started happening yesterday. For the other 4 branches (that we already had in GitHub when setting up the multi-branch pipeline), I see that the both the workspace and workspace@script dir have sources in them.

      For now, I have a rather crude way of getting around this

      properties([disableConcurrentBuilds()])
      
      node {
        env.BUILDSPACE = pwd()
        
        echo "BUILDSPACE is ${env.BUILDSPACE}"
        
        // check to see if sources are available in current dir. Else switch to @script dir 
        if (fileExists('package.json')) {
          echo 'package.json exists'
        } else {
          echo 'No package.json. Switching to script dir'
          env.BUILDSPACE = "${env.BUILDSPACE}" + '@script'
          echo "BUILDSPACE is ${env.BUILDSPACE}"
        }
      
         stage "Build Step"
          sh '''cd ${BUILDSPACE}
          #Do stuff here
          '''
      }
      
      

      I have attached the console log from the failed build (sanitized to remove actual GitHub URL info).

      It says that its "Running on master in /var/lib/jenkins/workspace/ZULUSCHED_DebugTool-6RUZGOFIV76HNXGYFRPCOHJUYYIS5YA2O7JZQWZG2RYSCS4XFCJQ"

      but then that directory is just empty

        Attachments

          Activity

          Hide
          matmok Tobias Mund added a comment -

          Put 'checkout scm' in your Jenkinsfile. It will check out your source to the empty directory.

          Show
          matmok Tobias Mund added a comment - Put 'checkout scm' in your Jenkinsfile. It will check out your source to the empty directory.
          Hide
          bijoyjth Bijoy Thomas added a comment -

          Tobias Mund Thank you for the comment. We did add the 'checkout scm' in the Jenkinsfile and it worked.

          Show
          bijoyjth Bijoy Thomas added a comment - Tobias Mund Thank you for the comment. We did add the 'checkout scm' in the Jenkinsfile and it worked.
          Hide
          matmok Tobias Mund added a comment -

          Closed issue because it was not a defect - putting  'checkout scm' in jenkinsfile did the job.

          Show
          matmok Tobias Mund added a comment - Closed issue because it was not a defect - putting  'checkout scm' in jenkinsfile did the job.
          Hide
          bytemaster Boris Folgmann added a comment -

          I'm experiencing the same problem with current Jenkins LTS and Pipeline.

          As I'm using the declarative syntax there is no checkout scm.

           

          Show
          bytemaster Boris Folgmann added a comment - I'm experiencing the same problem with current Jenkins LTS and Pipeline. As I'm using the declarative syntax there is no checkout scm.  
          Hide
          markewaite Mark Waite added a comment -

          Boris Folgmann this bug is describing a user misunderstanding in their use of scripted pipeline. They failed to include a checkout scm in their scripted step.

          You said:

          I'm experiencing the same problem with current Jenkins LTS and Pipeline.

          As I'm using the declarative syntax there is no checkout scm.

          The problem you're encountering is something different than the problem described by this bug. Please submit a separate bug report with details to describe how to duplicate the case you're seeing.

          I created a declarative pipeline job and confirmed that declarative pipeline performs a checkout as expected. That job uses a parallel step to check both Windows and Linux.

          Show
          markewaite Mark Waite added a comment - Boris Folgmann this bug is describing a user misunderstanding in their use of scripted pipeline. They failed to include a checkout scm in their scripted step. You said: I'm experiencing the same problem with current Jenkins LTS and Pipeline. As I'm using the declarative syntax there is no checkout scm. The problem you're encountering is something different than the problem described by this bug. Please submit a separate bug report with details to describe how to duplicate the case you're seeing. I created a declarative pipeline job and confirmed that declarative pipeline performs a checkout as expected. That job uses a parallel step to check both Windows and Linux.
          Hide
          malikos Omar Malik added a comment -

          This is my first Jenkins post.

          I have an issue, when I am trying to read a Jenkins file (from RTC) i get Access denied.

          I am really not sure how to continue or why my Jenkinsfile cannot be read from RTC. The Jenkinsfile is placed in the

          workspace@scripts directory.

            

          Show
          malikos Omar Malik added a comment - This is my first Jenkins post. I have an issue, when I am trying to read a Jenkins file (from RTC) i get Access denied. I am really not sure how to continue or why my Jenkinsfile cannot be read from RTC. The Jenkinsfile is placed in the workspace@scripts directory.   
          Hide
          markewaite Mark Waite added a comment -

          Omar Malik it won't help to ask a question as a comment on an unrelated bug report. Please refer to the documentation, mailing lists, chat channels, and other locations. The bug database is intentionally used for bug reports rather than answering technical questions.

          Show
          markewaite Mark Waite added a comment - Omar Malik it won't help to ask a question as a comment on an unrelated bug report. Please refer to the documentation , mailing lists , chat channels , and other locations. The bug database is intentionally used for bug reports rather than answering technical questions.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            bijoyjth Bijoy Thomas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: