Jenkins Job-DSL job to pass parameters to jenkins-pipeline while job creation

Viewed 361

I have a CI Seed Job DSL Job in jenkins which creates a jenkins pipeline job.Is there any possibilities to get parameters in CI Seed Job and pass the input parameters given in Seed job to the jenkins pipeline script.

Here in below example, how the schema name given as parameter can be updated in jenkins pipeline job when creating it


CI Seed Job Setup: 

 1. Configured one string parameter `SchemaName`
 2. DSL Script for jenkins pipeline job creation 
pipelineJob('job-name') {
  definition {
    cps {
      script('''
        pipeline {
            agent any
                stages {
                    stage('Stage 1') {
                        steps {
                echo $SchemaName
                        }
                    }
                    stage('Stage 2') {
                        steps {
                            echo 'logic'
                        }
                    }
                }
            }
        }
      '''.stripIndent())
      sandbox()     
    }
  }
}
0 Answers
Related