jjb: babeltrace: use clang-format-16
[lttng-ci.git] / scripts / lttng-modules / trigger-vanilla.groovy
CommitLineData
9e5c099a
MJ
1/**
2 * Copyright (C) 2017 - Michael Jeanson <mjeanson@efficios.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18import hudson.model.*
19import hudson.AbortException
20import hudson.console.HyperlinkNote
21import java.util.concurrent.CancellationException
22import org.eclipse.jgit.api.Git
23import org.eclipse.jgit.lib.Ref
24
25def kgitrepo = "git://git-mirror.internal.efficios.com/git/linux-all.git"
26def ondiskpath = build.getEnvironment(listener).get('WORKSPACE') + "/ondisk-refs"
27
28def trigger_jobs = [
29 'lttng-modules_master_build-vanilla',
5424b59b 30 'lttng-modules_stable-2.13_build-vanilla',
8be4ddf2 31 'lttng-modules_stable-2.12_build-vanilla',
9e5c099a 32 'lttng-modules_master_crossbuild-vanilla',
5424b59b 33 'lttng-modules_stable-2.13_crossbuild-vanilla',
8be4ddf2 34 'lttng-modules_stable-2.12_crossbuild-vanilla',
9e5c099a
MJ
35]
36
37def previous_tags = []
38def current_refs = []
39def current_tags = [] as Set
40
41// First try to load previous tags from disk
42try {
43 def input = new ObjectInputStream(new FileInputStream(ondiskpath))
44 previous_tags = input.readObject()
45 input.close()
46} catch (all) {
47 println("Failed to load previous tags from disk.")
48}
49
50println("Loaded " + previous_tags.size() + " tags from disk.")
51//println("Previous tags:")
52//for (tag in previous_tags) {
53// println(" - ${tag}")
54//}
55
56// Get current tag refs from git repository
57current_refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call();
58
59println("Loaded " + current_refs.size() + " tags from git repository.")
60//println("Current tags:")
61for (ref in current_refs) {
62 //println(" - " + ref.getName())
63 current_tags.add(ref.getName())
64}
65
66// Write currents tags to disk
67try {
68 def out = new ObjectOutputStream(new FileOutputStream(ondiskpath))
69 out.writeObject(current_tags)
70 out.close()
71} catch (all) {
72 println("Failed to write tags to disk")
73}
74
75// Debug
76//current_tags.add("this_is_a_test")
77
78// Compare tags
79current_tags.removeAll(previous_tags)
80
81// If there are new tags, trigger the builds
82if (current_tags.size() > 0) {
83 println("Found " + current_tags.size() + "new tags:")
84 for (tag in current_tags) {
85 println(" - ${tag}")
86 }
87
88 for (jobname in trigger_jobs) {
89 println("Triggering job : ${jobname}")
90 def job = Hudson.instance.getJob(jobname)
91
92 def params = [];
93 for (paramdef in job.getProperty(ParametersDefinitionProperty.class).getParameterDefinitions()) {
94 params += paramdef.getDefaultParameterValue();
95 }
96 def paramsAction = new hudson.model.ParametersAction(params)
97
98 def cause = new Cause.UpstreamCause(build)
99 def causeAction = new CauseAction(cause)
100
101 Hudson.instance.queue.schedule(job, 0, causeAction, paramsAction)
102 }
103} else {
104 println("No new tags, nothing to do.")
105}
106
107// EOF
This page took 0.033572 seconds and 4 git commands to generate.