Skip to content

Commit 3c760e9

Browse files
committed
Merge pull request #53 from adriaanm/multi-user
Multi user/repo/branch for jenkins & scabot.
2 parents a45d662 + 39aae09 commit 3c760e9

20 files changed

+76
-54
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,15 @@ knife vault create master scabot-keypair \
280280
--admins adriaan
281281
282282
knife vault create master scabot \
283-
--json $PWD/.chef/scabot.json \
283+
{
284+
"jenkins": {
285+
"token": "..."
286+
},
287+
"github": {
288+
"scala": {"token": "..."}
289+
"lampepfl": {"token": "..."}
290+
}
291+
}
284292
--search 'name:jenkins-master' \
285293
--admins adriaan
286294

attributes/default.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,5 @@
121121
default['master']['ec2-start-stop']['url'] = 'https://dl.dropboxusercontent.com/u/12862572/ec2-start-stop.hpi'
122122

123123
# SCABOT
124-
default['scabot']['jenkins']['user'] = "scala-jenkins"
125-
default['scabot']['github']['repo_user'] = "scala"
124+
default['scabot']['jenkins']['user'] = "scala-jenkins"
126125
end

libraries/job_blurbs.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ def scmBlurb(refspec)
144144
EOH
145145
end
146146

147-
def versionedJob(version, name)
148-
"scala-#{version}-#{name.gsub(/\//, '-')}"
147+
def versionedJob(repo, branch, name)
148+
"#{repo}-#{branch}-#{name.gsub(/\//, '-')}"
149149
end
150150

151151
def job(name)
152-
versionedJob(@version, name)
152+
versionedJob(@repo, @branch, name)
153153
end
154154

155155
def jvmSelect

recipes/_master-config-scabot.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@
5959
revision "master"
6060
end
6161

62-
# TODO: do not use node.set for sensitive stuff!!
63-
node.set['scabot']['github']['token'] = chef_vault_item("master", "scabot")['github']['token']
64-
node.set['scabot']['jenkins']['token'] = chef_vault_item("master", "scabot")['jenkins']['token']
65-
6662
template "#{scabotHome}/scabot.conf" do
6763
source 'scabot.conf.erb'
6864
user scabotUser
6965
sensitive true
66+
67+
variables({
68+
:scabotVault => chef_vault_item("master", "scabot")
69+
})
70+
7071
end
7172

7273
bash 'build scabot' do

recipes/_master-jenkins-jobs.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ class Blurbs
2121
end
2222

2323
# turn template path into jenkins job name
24-
def templDesc(version, path)
24+
def templDesc(user, repo, branch, path)
2525
blurbs = Blurbs.new
2626

27-
m = path.match(/templates\/default\/jobs\/(.*)\.xml\.erb$/)
27+
m = path.match(/templates\/default\/jobs\/#{user}\/(.*)\.xml\.erb$/)
2828
if m == nil
2929
[]
3030
else
3131
relativePath = m.captures.first
3232

33-
[ { :templatePath => "jobs/#{relativePath}.xml.erb",
33+
[ { :templatePath => "jobs/#{user}/#{relativePath}.xml.erb",
3434
:scriptName => "jobs/#{relativePath}",
35-
:jobName => blurbs.versionedJob(version, relativePath),
36-
:version => version
35+
:jobName => blurbs.versionedJob(repo, branch, relativePath),
36+
:user => user,
37+
:repo => repo, # the main repo (we may refer to other repos under the same user in these jobs)
38+
:branch => branch,
3739
}
3840
]
3941
end
@@ -55,11 +57,9 @@ def templDesc(version, path)
5557
# - 9
5658
# core-community: sbt, ensime, modules, ide,...
5759

58-
# create scala-$version-$jobName for every template under jobs/
59-
# TODO #16: add 2.12.x jobs
60-
%w{ 2.11.x }.each do | version |
60+
def expandJobTemplates(user, repo, branch)
6161
node.run_context.cookbook_collection["scala-jenkins-infra"].manifest[:templates]
62-
.flat_map { |mani| templDesc(version, mani['path']) }
62+
.flat_map { |mani| templDesc(user, repo, branch, mani['path']) }
6363
.each do | desc |
6464

6565
xml = File.join(Chef::Config[:file_cache_path], "#{desc[:jobName]}.xml")
@@ -77,6 +77,14 @@ def templDesc(version, path)
7777
end
7878
end
7979

80+
# TODO: make consistent with scabot.conf.erb by construction
81+
# (each github user for which we create jobs should have a corresponding top-level section in scabot.conf)
82+
# create scala-$branch-$jobName for every template under jobs/
83+
%w{ 2.11.x 2.12.x }.each do | branch |
84+
expandJobTemplates("scala", "scala", branch)
85+
end
86+
87+
8088
# TODO #10: make a view for each top-level directory under jobs/ that lists all jobs under it (scala-2.11.x-integrate, scala-2.11.x-release, scala-2.11.x-validate)
8189
# https://issues.jenkins-ci.org/browse/JENKINS-8927
8290
def viewXML(viewPrefix)
@@ -105,4 +113,4 @@ def viewXML(viewPrefix)
105113
<statusFilter>true</statusFilter>
106114
</listView>
107115
EOH
108-
end
116+
end

recipes/master-init.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
include_recipe "java"
1212

13-
# EBS -- must come before jenkins init since it mounts /var/lib/jenkins
14-
include_recipe "scala-jenkins-infra::_config-ebs"
13+
case node["platform"]
14+
when "amazon"
15+
# EBS -- must come before jenkins init since it mounts /var/lib/jenkins
16+
include_recipe "scala-jenkins-infra::_config-ebs"
17+
end
1518

1619
include_recipe "scala-jenkins-infra::_master-init-jenkins"
1720

recipes/worker-config.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# since jenkins's home dir is mounted on ephemeral storage (see chef/userdata/ubuntu-publish-c3.xlarge)
1313

1414

15-
include_recipe "scala-jenkins-infra::_config-ebs"
15+
case node["platform"]
16+
when "amazon"
17+
include_recipe "scala-jenkins-infra::_config-ebs"
18+
end
1619

1720
node["jenkinsHomes"].each do |jenkinsHome, workerConfig|
1821
case node["platform_family"]

templates/default/jobs/integrate/bootstrap.xml.erb renamed to templates/default/jobs/scala/integrate/bootstrap.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: %{ Stage a Scala distribution on sonatype using scripts/job/bootstrap.
88
It builds locker and uses it to build and publish the required modules as well as the
99
Scala compiler/library for this release, and generates an updated versions.properties

templates/default/jobs/integrate/ide.xml.erb renamed to templates/default/jobs/scala/integrate/ide.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "PR integration testing: IDE",
88
nodeRestriction: "public",
99
params: [

templates/default/jobs/integrate/main.xml.erb renamed to templates/default/jobs/scala/integrate/main.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<com.cloudbees.plugins.flow.BuildFlow plugin="[email protected]">
33
<%= flowProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "PR integration -- verify mergeability of PR",
88
params: [
99
{:name => "prDryRun", :desc => ""},

templates/default/jobs/release/main.xml.erb renamed to templates/default/jobs/scala/release/main.xml.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<com.cloudbees.plugins.flow.BuildFlow plugin="[email protected]">
33
<%= flowProject(
4-
repoUser: "scala",
5-
repoRef: @version,
6-
description: "TODO: Better description. Build, package and stage a Scala release. \nNightly downloads go to http://www.scala-lang.org/files/archive/nightly/#{@version}/\nRegular ones to http://www.scala-lang.org/files/archive/.",
4+
repoUser: @user,
5+
repoRef: @branch,
6+
description: "TODO: Better description. Build, package and stage a Scala release. \nNightly downloads go to http://www.scala-lang.org/files/archive/nightly/#{@branch}/\nRegular ones to http://www.scala-lang.org/files/archive/.",
77
params: [
88
{:name => "SCALA_VER_BASE", :desc => "When set, a release with version \"$SCALA_VER_BASE$SCALA_VER_SUFFIX\" will be built. Same effect as for tagging $repo_ref as \"v$SCALA_VER_BASE$SCALA_VER_SUFFIX\"."},
99
{:name => "SCALA_VER_SUFFIX", :desc => ""}

templates/default/jobs/release/package/unix.xml.erb renamed to templates/default/jobs/scala/release/package/unix.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala-dist",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "Run as part of the #{job("release/main")} flow.<p>" + %{Builds and uploads the universal and unix-specific artifacts for a
88
Scala release.<br>
99

templates/default/jobs/release/package/windows.xml.erb renamed to templates/default/jobs/scala/release/package/windows.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala-dist",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "Run as part of the #{job("release/main")} flow.<p>" + %{Builds and uploads the windows-specific artifacts for a Scala
88
release.<br>
99

templates/default/jobs/release/smoketest.xml.erb renamed to templates/default/jobs/scala/release/smoketest.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala-dist-smoketest",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "Run as part of the #{job("release/main")} flow." + %{ <br/> It runs the program in
88
https://github.com/scala/scala-dist-smoketest/tree/${repo_ref} to make sure all JARs of the distribution
99
contain classfiles. <br/> It downloads the archives for a Scala release from

templates/default/jobs/release/website/archives.xml.erb renamed to templates/default/jobs/scala/release/website/archives.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala-dist",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "<H1>Run as part of the #{job("release/main")} flow.</H1>" +
88
%{<p>It downloads the archives for a Scala release
99
from http://downloads.typesafe.com/scala/$version/index.html and

templates/default/jobs/release/website/update-api.xml.erb renamed to templates/default/jobs/scala/release/website/update-api.xml.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala-dist",
6-
repoRef: @version,
7-
description: "Update scala-lang's api/#{@version} symlink to point to api/$version",
6+
repoRef: @branch,
7+
description: "Update scala-lang's api/#{@branch} symlink to point to api/$version",
88
nodeRestriction: "linux && publish",
99
concurrent: false,
1010
params: [

templates/default/jobs/validate/main.xml.erb renamed to templates/default/jobs/scala/validate/main.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<com.cloudbees.plugins.flow.BuildFlow plugin="[email protected]">
33
<%= flowProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "PR validation -- called for every commit in every PR",
88
params: [
99
{:name => "prDryRun", :desc => ""},

templates/default/jobs/validate/publish-core.xml.erb renamed to templates/default/jobs/scala/validate/publish-core.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "PR validation: publish core",
88
nodeRestriction: "public",
99
params: [

templates/default/jobs/validate/test.xml.erb renamed to templates/default/jobs/scala/validate/test.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<project>
33
<%= githubProject(
4-
repoUser: "scala",
4+
repoUser: @user,
55
repoName: "scala",
6-
repoRef: @version,
6+
repoRef: @branch,
77
description: "PR validation: test suite",
88
nodeRestriction: "public",
99
params: [

templates/default/scabot.conf.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
scala: {
22
jenkins: {
3-
job: "scala-2.11.x-validate-main"
4-
jobPrefix: "scala-2.11.x-" // this will be stripped when reporting to github TODO: remove once it's computed as s"${github.repo}-${pull.base.ref}-"
3+
jobSuffix: "validate-main"
54
host: "<%=node['master']['jenkinsHost']%>"
65
user: "<%=node['scabot']['jenkins']['user']%>"
7-
token: "<%=node['scabot']['jenkins']['token']%>"
6+
token: "<%=@scabotVault['jenkins']['token']%>"
87
}
98
github: {
10-
user: "<%=node['scabot']['github']['repo_user']%>"
119
repo: "scala"
10+
branches: ["2.11.x", "2.12.x"]
1211
host: "api.github.com"
13-
token: "<%=node['scabot']['github']['token']%>"
12+
user: "scala"
13+
token: "<%=@scabotVault['github']['scala']['token']%>"
1414
}
1515
}

0 commit comments

Comments
 (0)