pipeline { agent { label "linux" } stages { stage("Checkout") { steps { checkout changelog: false, poll: false, scm: perforce( credential: 'Perforce-Credentials', populate: autoClean(delete: true, modtime: false, parallel: [enable: true, minbytes: '1024', minfiles: '1', threads: '4'], pin: null, quiet: true, replace: true, tidy: false), workspace: manualSpec( name: "${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}", spec: clientSpec( view: '''//path/abc/src/... //${P4_CLIENT}/... //path/def/src/... //${P4_CLIENT}/def/...''' ) ) ) p4unshelve (resolve: 'ay', shelf: '316076', credential: 'Perforce-Credentials', tidy: true, ignoreEmpty: true, workspace: manualSpec( name: "${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}", spec: clientSpec( view: '''//path/abc/src/... //${P4_CLIENT}/... //path/def/src/... //${P4_CLIENT}/def/...''' ) ) ) } } } }
This will run until the p4unshelve step, then it will throw a stacktrace:
P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification. Mapping '//P4_CLIENT/...' is not under '//jenkins-node-1-Test-0/...'. at com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser.handleErrorStr(ResultMapParser.java:146) at com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser.parseCommandResultMapIfIsInfoMessageAsString(ResultMapParser.java:98) at com.perforce.p4java.impl.mapbased.server.cmd.ClientDelegator.updateClient(ClientDelegator.java:212) at com.perforce.p4java.impl.mapbased.server.Server.updateClient(Server.java:1728) at com.perforce.p4java.impl.mapbased.client.Client.update(Client.java:528) at org.jenkinsci.plugins.p4.client.ClientHelper.updateClient(ClientHelper.java:191) at org.jenkinsci.plugins.p4.client.ClientHelper.clientLogin(ClientHelper.java:170) at org.jenkinsci.plugins.p4.client.ClientHelper.<init>(ClientHelper.java:104) at org.jenkinsci.plugins.p4.unshelve.UnshelveBuilder.updateChangeLog(UnshelveBuilder.java:141) at org.jenkinsci.plugins.p4.unshelve.UnshelveBuilder.unshelve(UnshelveBuilder.java:134) at org.jenkinsci.plugins.p4.unshelve.UnshelveBuilderStep.perform(UnshelveBuilderStep.java:42) at org.jenkinsci.plugins.p4.workflow.P4UnshelveStep$P4UnshelveStepExecution.run(P4UnshelveStep.java:133) at org.jenkinsci.plugins.p4.workflow.P4UnshelveStep$P4UnshelveStepExecution.run(P4UnshelveStep.java:119) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
This bug maybe a duplicate of JENKINS-70584
I also note that the manual according to Helix says to use ''' instead of """ to prevent early variable expansion which may break the build.
It is also unclear to me why I need to pass the workspace and credentials to the p4unshelve, the intention here is to really just sync the workspace and unshelve a change in it. Maybe this could have been better implemented using the checkout scm: perforce clause by adding another parameter "review" in addition to "change" (which can be used to pin the build to a specific change number or the latest by specifying "now"). Perhaps the documentation of the p4unshelve can be improved?
Perhaps the entire thing would be better implemented differently, e.g. p4.run() but that require one to permit dangerous functions signatures ...