forked from pangea-project/pangea-tooling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins_jobs_update_nci.rb
executable file
·199 lines (181 loc) · 8.18 KB
/
jenkins_jobs_update_nci.rb
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# Copyright (C) 2015-2016 Harald Sitter <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) version 3, or any
# later version accepted by the membership of KDE e.V. (or its
# successor approved by the membership of KDE e.V.), which shall
# act as a proxy defined in Section 6 of version 3 of the license.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
require_relative 'ci-tooling/lib/nci'
require_relative 'ci-tooling/lib/projects/factory'
require_relative 'lib/jenkins/project_updater'
Dir.glob(File.expand_path('jenkins-jobs/*.rb', __dir__)).each do |file|
require file
end
Dir.glob(File.expand_path('jenkins-jobs/nci/*.rb', __dir__)).each do |file|
require file
end
# Updates Jenkins Projects
class ProjectUpdater < Jenkins::ProjectUpdater
def initialize
@job_queue = Queue.new
@flavor = 'nci'
@projects_dir = "#{__dir__}/ci-tooling/data/projects"
JenkinsJob.flavor_dir = "#{__dir__}/jenkins-jobs/#{@flavor}"
super
end
private
# Append nci templates to list.
def all_template_files
files = super
files + Dir.glob("#{JenkinsJob.flavor_dir}/templates/**.xml.erb")
end
def populate_queue
all_builds = []
all_meta_builds = []
all_mergers = []
type_projects = {}
NCI.types.each do |type|
projects_file = "#{@projects_dir}/nci/#{type}.yaml"
projects = ProjectsFactory.from_file(projects_file,
branch: "Neon/#{type}")
type_projects[type] = projects
next unless type == 'unstable'
projects.each do |project|
branch = project.packaging_scm.branch
# FIXME: this is fairly hackish
dependees = []
# Mergers need to be upstreams to the build jobs otherwise the
# build jobs can trigger before the merge is done (e.g. when)
# there was an upstream change resulting in pointless build
# cycles.
branches = NCI.types.collect { |x| "Neon/#{x}" } << 'master'
next unless branch && branch.start_with?(*branches)
NCI.series.each_key do |d|
NCI.types.each do |t|
dependees << Builder.basename(d, t, project.component, project.name)
end
end
all_mergers << enqueue(NCIMergerJob.new(project,
dependees: dependees,
branches: branches))
end
end
watchers = {}
NCI.series.each_key do |distribution|
NCI.types.each do |type|
type_projects[type].each do |project|
jobs = ProjectJob.job(project,
distribution: distribution,
type: type,
architectures: NCI.architectures)
jobs.each { |j| enqueue(j) }
all_builds += jobs
# FIXME: presently not forcing release versions of things we have a
# stable for
next unless type == 'release'
next unless %w(neon-packaging calligra frameworks plasma applications kde-extras kde-std kde-req).include?(project.component)
watcher = WatcherJob.new(project)
next if watchers.key?(watcher.job_name) # Already have one.
watchers[watcher.job_name] = watcher
end
next if type.start_with?('testing')
# Meta builders.
all_builds.reject! { |j| !j.is_a?(ProjectJob) }
meta_args = {
type: type,
distribution: distribution,
downstream_jobs: all_builds
}
meta_builder = MetaBuildJob.new(meta_args)
all_meta_builds << enqueue(meta_builder)
enqueue(DailyPromoteJob.new(type: type,
distribution: distribution,
dependees: [meta_builder]))
# ISOs
NCI.architectures.each do |architecture|
dev_unstable_isoargs = { type: 'devedition-gitunstable',
distribution: distribution,
architecture: architecture,
metapackage: 'neon-desktop',
imagename: 'neon',
neonarchive: 'dev/unstable',
cronjob: 'H H * * *' }
enqueue(NeonIsoJob.new(dev_unstable_isoargs))
dev_unstable_dev_name = 'devedition-gitunstable-development'
dev_unstable_dev_isoargs = { type: dev_unstable_dev_name,
distribution: distribution,
architecture: architecture,
metapackage: 'neon-desktop',
imagename: 'neon-development',
neonarchive: 'dev/unstable',
cronjob: 'H H * * *' }
enqueue(NeonIsoJob.new(dev_unstable_dev_isoargs))
dev_stable_isoargs = { type: 'devedition-gitstable',
distribution: distribution,
architecture: architecture,
metapackage: 'neon-desktop',
imagename: 'neon',
neonarchive: 'dev/stable',
cronjob: 'H H * * *' }
enqueue(NeonIsoJob.new(dev_stable_isoargs))
user_release_isoargs = { type: 'useredition',
distribution: distribution,
architecture: architecture,
metapackage: 'neon-desktop',
imagename: 'neon',
neonarchive: 'user',
cronjob: 'H H * * 4' }
enqueue(NeonIsoJob.new(user_release_isoargs))
ko_user_release_isoargs = { type: 'devedition-gitstable',
distribution: distribution,
architecture: architecture,
metapackage: 'neon-desktop-ko',
imagename: 'neon-ko',
neonarchive: 'dev/stable',
cronjob: 'H H * * 4' }
enqueue(NeonIsoJob.new(ko_user_release_isoargs))
wayland_isoargs = { type: 'devedition-gitunstable',
distribution: distribution,
architecture: architecture,
metapackage: 'plasma-wayland-desktop',
imagename: 'plasma-wayland',
neonarchive: 'dev/unstable',
cronjob: 'H H * * *' }
enqueue(NeonIsoJob.new(wayland_isoargs))
end
end
end
watchers.each { |_, w| enqueue(w) }
merger = enqueue(MetaMergeJob.new(downstream_jobs: all_mergers))
progenitor = enqueue(
MgmtProgenitorJob.new(downstream_jobs: all_meta_builds,
blockables: [merger])
)
enqueue(MGMTPauseIntegrationJob.new(downstreams: [progenitor]))
aptly = enqueue(MGMTAptlyJob.new(dependees: [progenitor]))
# cleaner currently disregards deps entirely as technically it should be
# non-conflicting.
cleaner = enqueue(MGMTWorkspaceCleanerJob.new) # dependees: [progenitor]))
docker = enqueue(MGMTDockerJob.new(dependees: [progenitor]))
enqueue(MGMTToolingJob.new(downstreams: [docker],
dependees: [cleaner, aptly]))
end
end
if __FILE__ == $PROGRAM_NAME
updater = ProjectUpdater.new
updater.update
updater.install_plugins
end