How can I write job script and load it to jenkins to work ?

169 views
Skip to first unread message

Andy Billy

unread,
Apr 13, 2016, 9:55:34 PM4/13/16
to Jenkins Users
hi:)

   For the more and more jobs needed to be configured ,Is there a better way to configure them other than operating the ui workflow ?
   if I can write job config script and load it to jenkins ,that is pretty light work。
thanks.

Slide

unread,
Apr 13, 2016, 9:59:32 PM4/13/16
to Jenkins Users
There are two options that you might be interested in:


Both use a groovy DSL to either generate jobs or run pipelined tasks.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2e60b9ae-ba5c-4feb-86e0-242e48ace19a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Bywater

unread,
Apr 13, 2016, 10:04:34 PM4/13/16
to Jenkins Users
There's also Jenkins Job Builder - http://docs.openstack.org/infra/jenkins-job-builder/ - which isn't a plugin to Jenkins but creates and uploads Jenkins config.xml based off of YAML.

Richard.

Chris Knowlton

unread,
Apr 14, 2016, 2:55:21 PM4/14/16
to Jenkins Users
But jenkins job definitions are cached in memory.  I have been fighting this forever since there are fields stored in this cache which are not generally available to the user.

In my case, what I want to do is direct the job to a particular slave, because there is pre-built workspace there that I want the build to run in + I have tested and that slave is not busy + that workspace is not currently in use by any other build.

This works the FIRST time you generate a job with a particular name.  But the second time, jenkins has cached the name of the server that it successfully ran on.  And you can not change it.

The jobs are all ci loop jobs, they run all the time, so I need to re-use names to avoid filling up the jobs directory with useless data.

And of course I can not reload Jenkins Configuration every time I get a ci loop build.

I tried to use a groovy script to force jenkins to reload the configuration for that job only and that did not work at all.

Mark Waite

unread,
Apr 14, 2016, 3:16:10 PM4/14/16
to Jenkins Users
With a freestyle job, there is a checkbox in the job definition which will allow you to "Restrict where this project can be run".  Couldn't you change that from either a REST call or from a Selenium script?

Mark Waite

Chris Knowlton

unread,
Apr 15, 2016, 2:41:05 PM4/15/16
to Jenkins Users
Yes, and if that is valid slave name the REST call will complete.  But the next run will STILL run on the last slave it sucessfully completed on.

ChrisK
Reply all
Reply to author
Forward
0 new messages