6

I'm taking the build type i.e either Maven Job or Freestyle job as an input parameter (using the build parameterized plugin) and based on the input condition create the corresponding Job

My input parameter: "maven" (to create Maven job) , else block for freestyle Job.

if(params[build_type]=="maven"){
    mavenJob('example') {
        using(template_job)
          scm { 
            svn {
              location(svn_url)
            }
          } 
       } 
}
freeStyleJob('example') {
        using(template_job)
          scm { 
            svn {
              location(svn_url)
            }
          } 
       } 

I'm facing the following error message and I'm very new to groovy so please excuse. Looking forward for any suggestions.Thanks.

Processing provided DSL script ERROR: (script, line 1) No such property: params for class: script

Goku
  • 482
  • 1
  • 7
  • 22

1 Answers1

2

The Job DSL script inherits the build parameters as variables in your Job DSL. So if you have a parameter named build_type, you can use it as a variable.

if (build_type == "maven") {
    mavenJob('example') {
        using(template_job)
        scm { 
            svn {
                location(svn_url)
            }
        } 
    } 
}

See: User Power Moves: Parameterized Seed Job

Highway of Life
  • 22,803
  • 16
  • 52
  • 80