forked from coreos/fedora-coreos-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreams.groovy
52 lines (44 loc) · 1.76 KB
/
streams.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Canonical definition of all our streams and their type.
production = ['testing', 'stable', 'next']
development = ['testing-devel', 'next-devel']
mechanical = [/*'bodhi-updates', 'bodhi-updates-testing', 'branched', 'rawhide' */]
all_streams = production + development + mechanical
// Maps a list of streams to a list of GitSCM branches.
def as_branches(streams) {
return streams.collect{ [name: "origin/${it}"] }
}
// Retrieves the stream name from a branch name. Returns "" if branch doesn't
// correspond to a stream.
def from_branch(branch) {
assert branch.startsWith('origin/')
stream = branch['origin/'.length()..-1]
if (stream in all_streams) {
return stream
}
return ""
}
// Returns the default trigger for push notifications. This will trigger builds
// when SCMs change (either the pipeline code itself, or fedora-coreos-config).
def get_push_trigger() {
return [
// this corresponds to the "GitHub hook trigger for GITScm polling"
// checkbox; i.e. trigger a poll when a webhook event comes in at
// /github-webhook/ for the repo we care about
githubPush(),
// but still also force poll SCM every 30m as fallback in case hooks
// are down/we miss one
pollSCM('H/30 * * * *')
]
}
// Returns true if the build was triggered by a push notification.
def triggered_by_push() {
return (currentBuild.getBuildCauses('com.cloudbees.jenkins.GitHubPushCause').size() > 0)
}
// Starts a stream build.
def build_stream(stream) {
// Use `oc start-build` instead of the build step:
// https://bugzilla.redhat.com/show_bug.cgi?id=1580468
// With `--wait`, we'll error out if the build actually failed.
sh "oc start-build --wait fedora-coreos-pipeline -e STREAM=${stream}"
}
return this