Skip to content

Instantly share code, notes, and snippets.

@obcode
Last active August 29, 2015 14:15
Show Gist options
  • Save obcode/7072e2f047164dd73184 to your computer and use it in GitHub Desktop.
Save obcode/7072e2f047164dd73184 to your computer and use it in GitHub Desktop.
Jenkins - clone a template project
import hudson.model.*
// Begin Parameters
template = "md2html"
newname = template //
repoprefix = "ssh://git@ob.cs.hm.edu:8022/braun/14WS/compiler/md2html"
view = new ListView("braun-compiler")
noOfGroups = 12
// End Parameters
Hudson.instance.addView(view)
item = Hudson.instance.getItem(template)
for(grp in 1..noOfGroups)
{
grpstr = "-grp" + ((grp<10) ? "0"+grp : grp)
newName = name + grpstr
repository = repoprefix + grpstr
job = Hudson.instance.copy(item, newName)
job.scm = new hudson.plugins.git.GitSCM(repository)
job.save()
view.add(job)
println(" $item.name copied as $newName with $repository")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment