You can create a new hudson / jenkins work by simply doing:
FreeStyleProject proj = Hudson.getInstance().createProject(FreeStyleProject.class, NAMEOFJOB);
If you want to be able to handle updates (and you already have config.xml ):
import hudson.model.AbstractItem import javax.xml.transform.stream.StreamSource import jenkins.model.Jenkins final jenkins = Jenkins.getInstance() final itemName = 'name-of-job-to-be-created-or-updated' final configXml = new FileInputStream('/path/to/config.xml') final item = jenkins.getItemByFullName(itemName, AbstractItem.class) if (item != null) { item.updateByXml(new StreamSource(configXml)) } else { jenkins.createProjectFromXML(itemName, configXml) }
Make sure that you have the main .jar file before doing this.
Steve source share