System.exit(0) in groovy script using job-dsl-plugin crashes jenkins daemon

1,466 views
Skip to first unread message

pa...@autoagentframework.com

unread,
Nov 19, 2013, 1:21:40 PM11/19/13
to job-dsl...@googlegroups.com
We have jenkins 1.522 running on Centos 5. Using the job-dsl-lugin version 1.15.
I'm using it to create jobs from template job. The generator job is configured to use groovy script from file system. 
When I add System.exit(0) in that groovy script, as soon as the jenkins generator job is kicked off, the entire jenkins server goes down and we need to restart the daemon.

here's a watered down framework of the problem in groovy script:


mylist.eachLine {
  if (somecondition != null) {
    System.exit(0) //THIS CRASHES THE JENKINS SERVER PROCESS
  }
}

Rahul Somasunderam

unread,
Nov 19, 2013, 1:29:30 PM11/19/13
to job-dsl...@googlegroups.com
While sandboxing on the part of the plugin might help, it is not a great idea to call System.exit() in you DSL.
This might be better:

def badThing = myList.find {someCondition == null}
if (!badThing) {
  myList.each {
    ...
  }
}
--
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-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/3707790d-0fa2-442b-9746-a95c03f2b0cf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

pa...@autoagentframework.com

unread,
Nov 19, 2013, 1:33:06 PM11/19/13
to job-dsl...@googlegroups.com
Thanks Rahul.
Yes, I am just sandboxing, but was very surprised by the system crash. Even though I will not use System.exit() going forward, is this expected or is this a bug? thanks, paul bruno

Justin Ryan

unread,
Nov 19, 2013, 1:48:33 PM11/19/13
to job-dsl-plugin
There are techniques to sandbox a Groovy script, we just haven't
implemented them. There's plenty of examples around, specifically in
Jenkins. It should be a straightforward to port over into the job-dsl
plugin, via a pull request.
> https://groups.google.com/d/msgid/job-dsl-plugin/f014ebb4-b83e-4756-9e08-e5b24061c361%40googlegroups.com.

freckles

unread,
Mar 14, 2017, 8:00:58 AM3/14/17
to job-dsl-plugin
Is there a way to prevent this kind of behavior? meaning that if using, even by mistake, system.exit() then Jenkins won't die?
Thanks
Reply all
Reply to author
Forward
0 new messages