"p4sync" 的 Jenkins 管道语法

Jenkins Pipeline Syntax for "p4sync"

我正尝试在我的管道脚本中同步到 Perforce,但是是从 documentation I don't see a way to set the "workspace behavior", even though the plugin itself seems to have that capability

我希望 "workspace" 等同于设置 "Manual (custom view)" 我可以按照 here 在 UI 中进行配置。我需要将哪些参数传递给 p4sync 任务才能实现?

您将需要使用完整的 checkout DSL,p4sync DSL 只是基本的。最简单的方法是使用 SCM 列表中的片段生成器(管道语法 link)、select checkout: General SCM 然后 Perforce Software

然后您将能够定义详细视图。例如:

checkout([
  $class: 'PerforceScm', 
  credential: 'phooey1666', 
  populate: [
    $class: 'AutoCleanImpl', 
    delete: true, 
    modtime: false, 
    pin: '', 
    quiet: true, 
    replace: true
  ], 
  workspace: [
    $class: 'ManualWorkspaceImpl', 
    charset: 'none', 
    name: 'jenkins-${NODE_NAME}-${JOB_NAME}', 
    pinHost: false, 
    spec: [
      allwrite: true, 
      clobber: false, 
      compress: false, 
      line: 'LOCAL', 
      locked: false, 
      modtime: false, 
      rmdir: false, 
      streamName: '',
      view: '''
        //depot/... //jenkins-${NODE_NAME}-${JOB_NAME}/...
        -//depot/tests/... //jenkins-${NODE_NAME}-${JOB_NAME}/tests/...'''
    ]
  ]
])