How can I delete a job using Job DSL plugin(script) in Jenkins?

Srijani Ghosh picture Srijani Ghosh · Nov 18, 2015 · Viewed 8.2k times · Source

I am very new to Jenkins and Job DSL plugin. After a little research, I found how to create a job using DSL and now I am trying to delete a job using DSL. I know to disable a job using this following code:

//create new job
//freeStyleJob("MyJob1", closure = null);

job("MyJob1"){
  disabled(true);
}

It is working perfectly fine. But, I couldn't find any method to delete another job in jenkins.

Please help!

Thanks!

Answer

daspilker picture daspilker · Nov 18, 2015

To delete a job, you have to set the "Action for removed jobs" option to "Delete" in the "Process Job DSLs" build step configuration. Then remove the job from your script and run the seed job.