如何从 Jenkins 2 管道 groovy 脚本中取消搁置 p4

How to p4 unshelve from Jenkins 2 pipeline groovy script

我有一个 Jenkins2 管道 (groovy) 脚本,我希望能够(可选)使用 p4 SCM 取消搁置。我认为我需要这样的东西:

checkout(
    [$class: 'PerforceScm',
     credential: 'my-p4-credentials',
     populate:
         [$class: 'ForceCleanImpl',
          have: false,
          parallel: [enable: false,
              minbytes: '1024',
              minfiles: '1',
              path: '/usr/local/bin/p4',
              threads: '4'],
          pin: p4shelf,           // <--! this variable is the shelf CL
          quiet: true],
     workspace: [$class: 'TemplateWorkspaceImpl',
         charset: 'auto',
         format: 'jenkins-${NODE_NAME}-${JOB_NAME}',
         pinHost: false,
         templateName: p4branch]])

我仔细研究了 p4-plugin github 仓库。基本上,这不能一步完成。相反,首先,我们必须从 p4:

签出
checkout([$class: 'PerforceScm', ...])

然后,我们要做一个取消搁置的操作:

p4unshelve resolve: '', shelf: shelf, credential: 'jnsmith-p4-credentials'

工作如火如荼。