On 19.09.2013, at 20:47, nicolas de loof <[email protected]> wrote:

> it's just about using the adequate jenkins API
> Jenkins.instance.getItemByFullName("job").scheduleBuild(...)

Let's make this into a real example. Execution of two other jobs (in parallel 
even) below, plus copying their artifacts, all within a Groovy system build 
step.

----

hudson.model.queue.QueueTaskFuture build(String fullName) {
  def p = jenkins.model.Jenkins.instance.getItemByFullName(fullName)
  def thisR = Thread.currentThread().executable
  def f = p.scheduleBuild2(p.quietPeriod, new 
hudson.model.Cause.UpstreamCause(thisR))
  return f
}

def f1 = build('test-artifact-source-1')
def f2 = build('test-artifact-source-2')

// wait for both builds to finish
def b1 = f1.get()
def b2 = f2.get()

println b1.id
println b2.id

// added 'copy artifacts' because it was so easy -- not tested with execution 
on slave though, but it should work
b2.builtOn.createPath(b2.artifactsDir.canonicalPath).copyRecursiveTo(Thread.currentThread().executable.workspace)
b1.builtOn.createPath(b1.artifactsDir.canonicalPath).copyRecursiveTo(Thread.currentThread().executable.workspace)

return 0

----

http://javadoc.jenkins-ci.org is a great resource for stuff like this. And if 
you want to see how others accomplished something, well, almost all plugins, 
including build flow, are open source...

Regards
Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to