-
-
Save rameshz23/3d589203da355c1bfb907695f4207b5a to your computer and use it in GitHub Desktop.
create a jenkins job in the script console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins; | |
import hudson.model.FreeStyleProject; | |
import hudson.tasks.Shell; | |
job = Jenkins.instance.createProject(FreeStyleProject, 'job-name') | |
job.buildersList.add(new Shell('echo hello world')) | |
job.save() | |
build = job.scheduleBuild2(5, new hudson.model.Cause.UserIdCause()) | |
build.get() # Block until the build finishes | |
generatedJobs = build.getAction(javaposse.jobdsl.plugin.actions.GeneratedJobsBuildAction).getItems() | |
# FIXME skip .scheduleBuild2() on Folder jobs | |
generatedJobs.each { j -> j.scheduleBuild2(5, new hudson.model.Cause.UserIdCause()) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment