并行Jenkins管道阶段的常见设置

时间:2018-04-24 13:38:29

标签: jenkins jenkins-pipeline

我尝试设置Jenkins构建,将SVN同步到给定的更改列表,然后并行构建各种不同配置的代码。我有一个预建步骤,每个代理程序需要运行一次,无论代理程序将构建多少构建。我当前的声明性管道如下所示:

pipeline {
agent none
stages
{   
    stage('parallel')
    {
        failFast true

        parallel
        {
            stage('Release')
            {
                agent {
                    label {
                        label "windows"
                    }
                }                   
                steps
                {
                    checkout([$class: 'SubversionSCM',
                    additionalCredentials: [],
                    excludedCommitMessages: '',
                    excludedRegions: '',
                    excludedRevprop: '',
                    excludedUsers: '',
                    filterChangelog: false,
                    ignoreDirPropChanges: false,
                    includedRegions: '',
                    locations: [[credentialsId: 'SVN',
                        depthOption: 'infinity',
                        ignoreExternalsOption: false,
                        local: '.',
                        remote: 'https://my-repo']],
                    workspaceUpdater: [$class: 'UpdateUpdater']])

                    bat 'Prebuild.bat'
                    bat 'msbuild Game/Code/Application.sln "Release|x64"'
                }
            }
            stage('Debug Optimized')
            {
                agent {
                    label {
                        label "windows"
                    }
                }
                steps
                {
                    checkout([$class: 'SubversionSCM',
                    additionalCredentials: [],
                    excludedCommitMessages: '',
                    excludedRegions: '',
                    excludedRevprop: '',
                    excludedUsers: '',
                    filterChangelog: false,
                    ignoreDirPropChanges: false,
                    includedRegions: '',
                    locations: [[credentialsId: 'SVN',
                        depthOption: 'infinity',
                        ignoreExternalsOption: false,
                        local: '.',
                        remote: 'https://my-repo']],
                    workspaceUpdater: [$class: 'UpdateUpdater']])

                    bat 'Prebuild.bat'
                    bat 'msbuild Game/Code/Application.sln "Debug Optimized|x64"'
                }
            }
        }
    }
}
}

虽然这有效但a)它不可维护(我有大约20个配置来构建现实,我不想保留20份我的scm设置),b)它的每个阶段运行一次结账/预建,而不是每个代理运行一次。我注意到代理商有一个默认的结账,但据我所知,这并不适用于SVN。

有没有更好的方法来做并行阶段呢?

1 个答案:

答案 0 :(得分:0)

你听说过Jenkins Multijob插件吗? https://wiki.jenkins.io/display/JENKINS/Multijob+Plugin

它能满足您的需求吗?

当你的一个工作完成时,你也有可能建立下游工作。

相关问题