forked from pangea-project/pangea-tooling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-projects.rb
executable file
·106 lines (95 loc) · 4.03 KB
/
update-projects.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
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# Copyright (C) 2014-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/kci'
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
# Updates Jenkins Projects
class ProjectUpdater < Jenkins::ProjectUpdater
def initialize
super
JenkinsJob.flavor_dir = "#{__dir__}/jenkins-jobs/"
end
private
def populate_queue
all_metas = []
all_promoters = []
all_mergers = []
type_projects = {}
KCI.types.each do |type|
ProjectsFactory::Debian.instance_variable_set(:@url_base,
'git.debian.org:/git')
file = "#{__dir__}/ci-tooling/data/projects/kci.yaml"
projects = ProjectsFactory.from_file(file, branch: "kubuntu_#{type}")
type_projects[type] = projects
end
KCI.series.each_key do |distribution|
KCI.types.each do |type|
projects = type_projects.fetch(type, nil)
all_builds = projects.collect do |project|
if type == 'unstable' && distribution == KCI.series.keys[0]
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.
KCI.series.each_key do |d|
KCI.types.each do |t|
dependees << BuildJob.build_name(d, t, project.name)
end
end
all_mergers << enqueue(MergeJob.new(project, dependees: dependees))
end
enqueue(BuildJob.new(project, type: type, distribution: distribution))
end
all_promoters << enqueue(DailyPromoteJob.new(type: type,
distribution: distribution,
dependees: all_builds))
# This could actually returned into a collect if placed below
all_metas << enqueue(MetaBuildJob.new(type: type,
distribution: distribution,
downstream_jobs: all_builds))
# all_isos is actually unused
KCI.architectures.each do |architecture|
isoargs = { type: type,
distribution: distribution,
architecture: architecture }
enqueue(IsoJob.new(isoargs))
end
enqueue(MetaIsoJob.new(type: type, distribution: distribution))
end
end
enqueue(MGMTDockerCleanupJob.new(arch: 'amd64'))
merger = enqueue(MetaMergeJob.new(downstream_jobs: all_mergers))
enqueue(MgmtProgenitorJob.new(downstream_jobs: all_metas,
blockables: [merger]))
enqueue(MGMTPauseIntegrationJob.new(downstreams: all_metas))
docker = enqueue(MGMTDockerJob.new(dependees: all_metas + all_promoters))
enqueue(MGMTToolingJob.new(downstreams: [docker]))
end
end
if __FILE__ == $PROGRAM_NAME
updater = ProjectUpdater.new
updater.update
updater.install_plugins
end