You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Perforce与Jenkins Pipeline中结合自定义视图映射使用流

Using Perforce Streams with Custom View Mappings in Jenkins Pipeline

Got it, let’s adjust your existing Perforce checkout code to work with streams and custom view mappings. The key change is swapping out ManualWorkspaceImpl for StreamWorkspaceImpl (designed specifically for stream workspaces) and adding your custom view rules alongside the stream configuration.

Updated Checkout Code

Here’s the modified version of your checkout step, with comments highlighting the key changes:

checkout scm: [
    $class: 'PerforceScm',
    credential: 'me', // Keep your existing credential
    populate: [
        $class: 'AutoCleanImpl',
        delete: true,
        modtime: false,
        pin: '',
        quiet: true,
        replace: true // Keep your existing populate settings
    ],
    workspace: [
        $class: 'StreamWorkspaceImpl', // Changed from ManualWorkspaceImpl
        charset: 'utf8', // Keep your existing charset
        name: 'jenkins-${NODE_NAME}-${JOB_NAME}', // Reuse your dynamic workspace name
        pinHost: false,
        streamName: '//depot/your-stream-path', // Replace with your actual Perforce stream (e.g., //depot/main/my-app-stream)
        spec: [
            allwrite: true,
            clobber: false,
            compress: false,
            line: 'LOCAL',
            locked: false,
            modtime: false,
            rmdir: false,
            // Add your custom view mappings here
            view: '''
                //depot/your-stream-path/src/... //jenkins-${NODE_NAME}-${JOB_NAME}/src/...
                -//depot/your-stream-path/src/test/... //jenkins-${NODE_NAME}-${JOB_NAME}/src/test/...
                //depot/shared-libs/... //jenkins-${NODE_NAME}-${JOB_NAME}/shared-libs/...
            '''
        ]
    ]
]

Key Explainers

  • StreamWorkspaceImpl: This workspace type is built for Perforce streams, so it natively understands stream inheritance and default view rules. You just need to point it to your stream via streamName.
  • Custom View Mappings: The view field lets you override or extend the stream’s default view. Use Perforce’s standard view syntax:
    • Lines starting with - exclude paths
    • Use ... for recursive mappings
    • Make sure the target workspace path matches the dynamic name you defined (jenkins-${NODE_NAME}-${JOB_NAME})
  • Keep Existing Settings: All your original populate and workspace configs (like charset, name) can stay—we’re just adding stream support and custom views.

Important Notes

  • Test your view mappings first in a local Perforce client to make sure they pull exactly the files you need.
  • Ensure your Jenkins Perforce plugin is up to date (version 1.10+ recommended for full stream workspace support).
  • If your stream uses a parent stream, the custom view will merge with the parent’s view rules (Perforce’s standard view precedence applies).

内容的提问来源于stack exchange,提问作者Mobile Ben

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:36:21