Pass (same) parameters to multiple build jobs in a Jenkins pipeline Pass (same) parameters to multiple build jobs in a Jenkins pipeline jenkins jenkins

Pass (same) parameters to multiple build jobs in a Jenkins pipeline


I think you can use the parameters on the pipeline level and just pass the parameters in build calls.

//This will kick of the three pipeline scripts required to do a release in PROD pipeline {   agent any    parameters{        string(name: 'service1', defaultValue: 'NA', description: 'Verison' )        string(name: 'service2', defaultValue: 'NA', description: 'Verison' )        string(name: 'service3', defaultValue: 'NA', description: 'Verison' )    }   stages   {      stage('Invoke pipeline primary') {         steps {            build job: 'primary', parameters: ([] + params)         }      }      stage('Invoke pipeline secondary') {         steps {            build job: 'secondary', parameters: ([] + params)         }      }      stage('backup') {         steps {            build job: 'backup', parameters: ([] + params)         }      }   }} 


I mostly use scripted approach and something like the below works:

    def all_params = [            string(name: 'service1', defaultValue: 'NA', description: 'Version' ),            string(name: 'service2', defaultValue: 'NA', description: 'Version' ),            string(name: 'service3', defaultValue: 'NA', description: 'Version' ),        ]    properties([parameters(all_params)])

It should be possible to wrap the above code in a script block and use it in a declarative pipeline as well.