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.