1 |
|
|
|
1 |
import groovy.time.*
|
2 |
2 |
import hudson.model.*
|
3 |
3 |
import hudson.console.ModelHyperlinkNote
|
4 |
4 |
|
|
5 |
// allowed time since previous build
|
|
6 |
max_time_diff = new TimeDuration(8,0,0,0)
|
|
7 |
max_time = max_time_diff.getAgo()
|
|
8 |
|
5 |
9 |
// Dependency Data
|
6 |
10 |
|
7 |
11 |
dependencies = [
|
... | ... | |
615 |
619 |
logMessage("Job ${job} not found!")
|
616 |
620 |
return
|
617 |
621 |
}
|
|
622 |
job.enable()
|
|
623 |
|
|
624 |
last = job.getLastBuild()
|
|
625 |
if ((last.result == Result.SUCCESS || last.result == Result.UNSTABLE) && last.getTime() > max_time) {
|
|
626 |
time_diff = TimeCategory.minus(new Date(), last.getTime())
|
|
627 |
logMessage(" Skipping ${linkTo(job)}, built ${time_diff} ago")
|
|
628 |
name = build.project.name
|
|
629 |
status[job.name] = last;
|
|
630 |
startableDownstreams(job.name).each { project -> scheduleBuild(project, parameters) }
|
|
631 |
return
|
|
632 |
}
|
618 |
633 |
|
619 |
634 |
logMessage(" Scheduling build for ${linkTo(job)}")
|
620 |
635 |
parameters = parameters.collect { parameter ->
|
621 |
636 |
new StringParameterValue(parameter.key, parameter.value)
|
622 |
637 |
}
|
623 |
638 |
parametersAction = new ParametersAction(parameters)
|
624 |
|
job.enable()
|
625 |
639 |
run = job.scheduleBuild2(0, new Cause.UpstreamCause(build), parametersAction)
|
626 |
640 |
if (run) {
|
627 |
641 |
running << run
|
... | ... | |
705 |
719 |
|
706 |
720 |
runHook("Running finish hook job", "distribution-finish-lsp-famula-nightly", parameters)
|
707 |
721 |
|
708 |
|
logMessage("Enabling all jobs")
|
709 |
|
dependencies.each {
|
710 |
|
job = Hudson.instance.getJob(it.key)
|
711 |
|
if (job) job.enable()
|
712 |
|
}
|
713 |
|
|
714 |
722 |
// Report and build result
|
715 |
|
|
716 |
723 |
unstable = status.findAll { entry -> entry.value.result == Result.UNSTABLE } *.value
|
717 |
724 |
if (unstable) {
|
718 |
725 |
println "${unstable.size} unstable build(s):"
|
... | ... | |
726 |
733 |
for (build in failed) {
|
727 |
734 |
println " ${build.result} ${linkTo(build.project)}, ${linkTo(build)}"
|
728 |
735 |
}
|
729 |
|
return -1
|
730 |
736 |
}
|
|
737 |
skipped = dependencies.findAll {
|
|
738 |
job = Hudson.instance.getJob(it.key)
|
|
739 |
job && job.disabled
|
|
740 |
} *.key
|
|
741 |
if (skipped) {
|
|
742 |
println "${skipped.size} skipped jobs(s):"
|
|
743 |
skipped.each { println " ${linkTo(Hudson.instance.getJob(it))}" }
|
|
744 |
}
|
|
745 |
|
|
746 |
logMessage("Enabling all jobs")
|
|
747 |
dependencies.each {
|
|
748 |
job = Hudson.instance.getJob(it.key)
|
|
749 |
if (job) job.enable()
|
|
750 |
}
|
|
751 |
|
|
752 |
return failed ? -1 : 0
|