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

Lightweight Checkout failure to find jenkinsfile when jenkinsfile is in a subfolder

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • p4-plugin
    • Jenkins 2.138.2
      p4-plugin 1.9.3

      Our repository has several jenkinsfile in different locations, for different projects, e.g:

      //depot/branches/branch1/jenkinsfile.groovy
      //depot/branches/branch1/projects/proj1/jenkinsfile.groovy

      The second jenkinsfile describes the pipeline script for only what is required for project 'proj1' in branch 'branch1', while the first will build everything for integration testing purposes. They're used in different pipelines, however for both use cases the branch is

      //depot/branches/branch1/...

      I have two multibranch pipelines configured, both searching for branches under //depot/branches/* but with the jenkinsfile Script Path of each being 'jenkinsfile.groovy' and 'projects/proj1/jenkinsfile.groovy' respectively.

      Both projects find the branch 'branch1' and start a jenkins job to obtain the jenkinsfile. The job using the top-level jenkinsfile works correctly, however I get the following issue when the jenkinsfile is in a subfolder (in the job log, not the polling log, when attempting to obtain the jenkinsfile):

      Started by user Alisdair Robertson
      ... p4 dirs //depot/branches/* +
      ... p4 changes -m1 //depot/branches/branch1/... +
      ERROR: Could not do lightweight checkout, falling back to heavyweight
      com.perforce.p4java.exception.RequestException: //jenkinsTemp-xx-xx-xx-xx-xx/projects/proj1/jenkinsfile.groovy - file(s) not in client view.	at com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser.handleWarningStr(ResultMapParser.java:164)
      	at com.perforce.p4java.impl.mapbased.rpc.OneShotServerImpl.execStreamCmd(OneShotServerImpl.java:545)
      	at com.perforce.p4java.impl.mapbased.rpc.OneShotServerImpl.execStreamCmd(OneShotServerImpl.java:461)
      	at com.perforce.p4java.impl.mapbased.server.cmd.BaseDelegator.execStreamCmd(BaseDelegator.java:163)
      	at com.perforce.p4java.impl.mapbased.server.cmd.PrintDelegator.getFileContents(PrintDelegator.java:56)
      	at com.perforce.p4java.impl.mapbased.server.Server.getFileContents(Server.java:2288)
      	at org.jenkinsci.plugins.p4.scm.P4SCMFile.content(P4SCMFile.java:145)
      Caused: java.io.IOException
      	at org.jenkinsci.plugins.p4.scm.P4SCMFile.content(P4SCMFile.java:147)
      	at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:338)
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:104)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:303)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Checking out p4-xx-xx-xx-xx-xx-//depot/branches/branch1/... //jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}/...
      //depot/branches/branch1/projects/proj1/jenkinsfile.groovy //jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}/jenkinsfile.groovynull into /srv/jenkins/workspace/branch1-XXX@script to read projects/proj1/jenkinsfile.groovy
      ... p4 client -o jenkins-master-Active-proj1_test_incremental-branch1--1 +
      ... p4 info +
      ... p4 info +
      ... p4 client -i +
      ... p4 counter change +
      ... p4 changes -m1 -ssubmitted //jenkins-master-Active-proj1_test_incremental-proj1_d___ +
      Building on Node: master
      ... p4 client -o jenkins-master-Active-proj1_test_incremental-branch1--1 +
      ... p4 info +
      ... p4 info +
      ... p4 client -i +
      
      ... etc ...
      

       
      I would expect that this should work the same whether the jenkinsfile is in the root of a branch, or a subfolder.

          [JENKINS-54382] Lightweight Checkout failure to find jenkinsfile when jenkinsfile is in a subfolder

          Dave Miller added a comment - - edited

          We just hit this on an upgrade from 1.8.7 to 1.9.2. Totally breaks existing multibranch pipelines with the Jenkinsfile in a subdirectory. For some reason I haven't fully figured out yet, the heavyweight checkout is failing for other reasons.

          Edit: The workspace mapping is ambiguous, and so the Jenkinsfile is being stuck in the root, rather than in the correct relative path. This results in the build breaking on heavyweight checkout. Not actually related to this bug, but it's such a longstanding issue, it'll take some time to dig our way out of it, unless the lightweight checkout is fixed.

          Dave Miller added a comment - - edited We just hit this on an upgrade from 1.8.7 to 1.9.2. Totally breaks existing multibranch pipelines with the Jenkinsfile in a subdirectory. For some reason I haven't fully figured out yet, the heavyweight checkout is failing for other reasons. Edit: The workspace mapping is ambiguous, and so the Jenkinsfile is being stuck in the root, rather than in the correct relative path. This results in the build breaking on heavyweight checkout. Not actually related to this bug, but it's such a longstanding issue, it'll take some time to dig our way out of it, unless the lightweight checkout is fixed.

          Paul Allen added a comment -

          The view mapping was changed to support inclusionary and exclusionary mappings, but the way the Jenkinsfile was mapped would cause issues for subdirectories.  I have submitted a fix yesterday for this issue (along with some test to cover subdirectories); you can access the latest build here:

          https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/293/

          I'll push this out in a patch release fairly soon. If you are able to try the fix out and let me know would be awesome.

          Paul Allen added a comment - The view mapping was changed to support inclusionary and exclusionary mappings, but the way the Jenkinsfile was mapped would cause issues for subdirectories.  I have submitted a fix yesterday for this issue (along with some test to cover subdirectories); you can access the latest build here: https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/293/ I'll push this out in a patch release fairly soon. If you are able to try the fix out and let me know would be awesome.

          Tested the snapshot build and the behaviour is now what I'd expect! Thanks!

          Alisdair Robertson added a comment - Tested the snapshot build and the behaviour is now what I'd expect! Thanks!

          Paul Allen added a comment -

          Thank you for verifying the behaviour. 

          Paul Allen added a comment - Thank you for verifying the behaviour. 

          Paul Allen added a comment -

          Ready for release.

          Paul Allen added a comment - Ready for release.

          Paul Allen added a comment -

          Released in 1.9.4

          Paul Allen added a comment - Released in 1.9.4

            p4paul Paul Allen
            alisdair_robertson Alisdair Robertson
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: