Passing arguments from seed job

1,349 views
Skip to first unread message

Jeff Winnett

unread,
Oct 12, 2016, 3:42:39 PM10/12/16
to job-dsl-plugin
Hello.  I have a seed job that runs a DSL script to create another job.  I want the seed job to be able to run the same DSL script multiple times, and have the seed job pass a different argument to the DSL script each time, e.g. 'Test' or 'Prod' so that both 'Test' and 'Prod' jobs are built.  How can I get the seed job to pass an argument to a DSL script?  I believe then, in the DSL script, I will use the 'args[]' variable to retrieve the passed-in argument, right?

Daniel Spilker

unread,
Oct 12, 2016, 4:04:42 PM10/12/16
to job-dsl...@googlegroups.com

On Wed, Oct 12, 2016 at 9:42 PM, Jeff Winnett <winne...@gmail.com> wrote:
Hello.  I have a seed job that runs a DSL script to create another job.  I want the seed job to be able to run the same DSL script multiple times, and have the seed job pass a different argument to the DSL script each time, e.g. 'Test' or 'Prod' so that both 'Test' and 'Prod' jobs are built.  How can I get the seed job to pass an argument to a DSL script?  I believe then, in the DSL script, I will use the 'args[]' variable to retrieve the passed-in argument, right?

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/a5059bd2-b91e-47b0-95e7-85b3d1abbfca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Winnett

unread,
Oct 13, 2016, 1:24:06 PM10/13/16
to job-dsl-plugin
Hi, Daniel.
If I understand, you are suggesting that I:
1)  modify my job generator script (the script that I want to run more than once, using a parameter to determine whether a 'ITG' or 'PRO' build job is created) to read an environment variable that would contain the appropriate value ('test' or 'prod'), and
2)  modify my seed job to set the parameter to one of the two values, run the job generator script, reset the parameter to the other value, and then run the job generator script again.

Unfortunately, that doesn't seem to work, or more likely, I'm doing it incorrectly.  Below is a snip of my DSL code that generates my seed job (yes, I'm also using DSL to create my seed job).  When I then look at the seed job configuration I see the parameter being set, then immediately reset, and only one generated job is created, using the 2nd value of the parameter.

I think part of my problem is that the same job generator DSL script is being run more than once, and I have no way of having it read different env vars during different executions.

Thanks.

  // Set a parameter to create ITG build jobs. 
  parameters { 
    stringParam('myEnv', 'ITG', 'ITG or PRO')
  }

  // Create the build steps to build the PWAXApps jobs. 
  steps {
    dsl {
      external('PWAXAppsWebTestGenerator.groovy')
      removeAction('DELETE')
      removeViewAction('DELETE')
    }
  }

  // Reset the parameter to create PRO build jobs. 
  parameters { 
    stringParam('myEnv', 'PRO', 'ITG or PRO')
  }

  // Create the build steps to build the PWAXApps jobs. 
  steps {
    dsl {
      external('PWAXAppsWebTestGenerator.groovy')
      removeAction('DELETE')
      removeViewAction('DELETE')
    }
  }

Jeff Winnett

unread,
Oct 13, 2016, 1:48:16 PM10/13/16
to job-dsl-plugin
Also, one final (I hope) thing, I'd like it to be silent, that is, the seed job runs and generates the different 'main' jobs without any prompts for user input.


On Wednesday, October 12, 2016 at 12:42:39 PM UTC-7, Jeff Winnett wrote:
Reply all
Reply to author
Forward
0 new messages