简体   繁体   English

Jenkins 多作业管道的 Groovy 脚本

[英]Groovy script for a Jenkins multijob pipeline

I have a multijob pipeline that triggers several other builds to run.我有一个触发其他几个构建运行的多作业管道。 It takes in a couple of choice parameters (PRODUCT and BRANCH) to separate the builds into different groups.它需要几个选择参数(PRODUCT 和 BRANCH)来将构建分成不同的组。 The UI was easy to set up and works well. UI 易于设置且运行良好。 Now I need to transfer the same functionality onto a Groovy script instead of using the UI.现在我需要将相同的功能转移到 Groovy 脚本上,而不是使用 UI。 I have the script below, but it's not working.我有下面的脚本,但它不起作用。 I'm getting the following error message: eCaught: groovy.lang.MissingMethodException: No signature of method...我收到以下错误消息: eCaught: groovy.lang.MissingMethodException: No signature of method...

I'm pretty sure my syntax is way off:我很确定我的语法离题了:

 pipeline { parameters { choice( choices: ['A', 'B'], description: 'Select which set of artifacts to trigger', name: 'PRODUCT') choice( choices: ['develop', 'release'], description: 'Select which branch to build the artifacts from', name: 'BRANCH') } stages { stage ('Build') { when { expression { env.PRODUCT == 'A' && env.BRANCH == 'release' } } steps { parallel ( build (job: '../../Builds/artifact1/release'), build (job: '../../Builds/artifact2/release'), build (job: '../../Builds/artifact3/release'), ) } when { expression { env.PRODUCT == 'A' && env.BRANCH == 'develop' } } steps { parallel ( build (job: '../../Builds/artifact1/develop'), build (job: '../../Builds/artifact2/develop'), build (job: '../../Builds/artifact3/develop'), ) } when { expression { env.PRODUCT == 'B' && env.BRANCH == 'release' } } steps { parallel ( build (job: '../../Builds/artifact4/release'), build (job: '../../Builds/artifact5/release'), build (job: '../../Builds/artifact6/release'), } when { expression { env.PRODUCT == 'B' && env.BRANCH == 'develop' } } steps { parallel ( build (job: '../../Builds/artifact4/develop'), build (job: '../../Builds/artifact5/develop'), build (job: '../../Builds/artifact6/develop'), ) } } } }

Inside the steps, run the build in a script segment, it might help在这些步骤中,在脚本段中运行构建,它可能会有所帮助

script{
                            j1BuildResult = build job: "Compile", propagate: true, wait: true, parameters: [
                                    //booleanParam(name: 'portal', value: env.PORTAL),
                                    string(name: 'BRANCH', value: params.BRANCH),
                                    booleanParam(name: 'portal', value: false),
                                    string(name: 'db', value: params.SCHEME_NAME),
                            ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM