简体   繁体   中英

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. The UI was easy to set up and works well. Now I need to transfer the same functionality onto a Groovy script instead of using the 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...

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),
                            ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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