Skip to content

Commit e3d85c4

Browse files
committed
Hierarchical script/job config layout
1 parent 0103a9e commit e3d85c4

File tree

10 files changed

+86
-79
lines changed

10 files changed

+86
-79
lines changed

libraries/job_blurbs.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,19 @@ def scmBlurb
6262
EOH
6363
end
6464

65+
def versionedJob(version, name)
66+
"scala-#{version}-#{name.gsub(/\//, '-')}"
67+
end
68+
69+
def job(name)
70+
versionedJob(@version, name)
71+
end
72+
6573
def scriptBuild
66-
<<-EOH.gsub(/^ {4}/, '')
74+
<<-EOH.gsub(/^ /, '')
6775
<hudson.tasks.Shell>
6876
<command>#!/bin/bash -ex
69-
source scripts/jobs/$JOB_NAME
77+
source scripts/#{@scriptName}
7078
</command>
7179
</hudson.tasks.Shell>
7280
EOH

recipes/_master-config-jobs.rb

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,48 @@
1515
end
1616
end
1717

18-
# TODO: auto-discover templates, organize them in views according to subdirs under templates/defaults
19-
# run_context.cookbook_collection[cookbook_name].manifest[:templates] is an array of
20-
# {"name"=>"scala-release-2.11.x-unix.xml.erb",
21-
# "path"=>"templates/default/scala-release-2.11.x/scala-release-2.11.x-unix.xml.erb", ...}
2218

23-
%w(scala-release-2.11.x scala-release-2.11.x-build scala-release-2.11.x-unix scala-release-2.11.x-windows scala-release-2.11.x-smoketest scala-release-2.11.x-scala-lang scala-release-2.11.x-scala-lang-update-current).each do |name|
24-
xml = File.join(Chef::Config[:file_cache_path], "#{name}.xml")
19+
# TODO: is there no shorter way??
20+
class Blurbs
21+
include ScalaJenkinsInfra::JobBlurbs
22+
end
23+
24+
# turn template path into jenkins job name
25+
def templDesc(version, path)
26+
blurbs = Blurbs.new
2527

26-
template xml do
27-
source "scala-release-2.11.x/#{name}.xml.erb"
28-
helpers(ScalaJenkinsInfra::JobBlurbs)
28+
m = path.match(/templates\/default\/jobs\/(.*)\.xml\.erb$/)
29+
if m == nil
30+
[]
31+
else
32+
relativePath = m.captures.first
33+
34+
[ { :templatePath => "jobs/#{relativePath}.xml.erb",
35+
:scriptName => "jobs/#{relativePath}",
36+
:jobName => blurbs.versionedJob(version, relativePath),
37+
:version => version
38+
}
39+
]
2940
end
41+
end
42+
43+
# create scala-$version-$jobName for every template under jobs/
44+
%w{ 2.11.x }.each do | version |
45+
node.run_context.cookbook_collection["scala-jenkins-infra"].manifest[:templates]
46+
.flat_map { |mani| templDesc(version, mani['path']) }
47+
.each do | desc |
48+
49+
xml = File.join(Chef::Config[:file_cache_path], "#{desc[:jobName]}.xml")
50+
51+
template xml do
52+
variables(desc)
53+
54+
source desc[:templatePath]
55+
helpers(ScalaJenkinsInfra::JobBlurbs)
56+
end
3057

31-
jenkins_job name do
32-
config xml
58+
jenkins_job desc[:jobName] do
59+
config xml
60+
end
3361
end
3462
end

templates/default/scala-release-2.11.x/scala-release-2.11.x-build.xml.erb renamed to templates/default/jobs/integrate/bootstrap.xml.erb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@
33
<%= githubProject(
44
repoUser: "scala",
55
repoName: "scala",
6-
repoRef: "2.11.x",
7-
description: %{ This job publishes a Scala distribution to maven using
8-
https://github.com/scala/jenkins-scripts/blob/master/job/scala-release-2.11.x. It
9-
builds locker and uses it to build and publish the required modules as well as the
6+
repoRef: @version,
7+
description: %{ Stage a Scala distribution on sonatype using scripts/job/bootstrap.
8+
It builds locker and uses it to build and publish the required modules as well as the
109
Scala compiler/library for this release, and generates an updated versions.properties
1110
that captures the modules/STARR used.
1211
13-
<p> This job is run nightly to build nightly releases (unless HEAD of scala/scala is
14-
tagged, on which it builds a release and stages it on sonatype).
15-
16-
<p> On building a release, the remaining tasks are to close the staging repo (see
17-
https://github.com/adriaanm/binfu/blob/master/sonafu.sh for scripts), possibly re-run
18-
the downstream scala-release-2.11.x-dist job once all external artifacts are in place
19-
(akka-actor), and send out some emails.
12+
<p> This job is run on every merge to publish a "nightly" snapshot, and on every tag, to stage a full release on sonatype.
2013
2114
<p> Use github.com/scala/make-release-notes to build the release notes.
2215
}.gsub(/^ /, ''),

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<com.cloudbees.plugins.flow.BuildFlow plugin="[email protected]">
3-
<description>Run as downstream job from scala-release-2.11.x.&#xd;
4-
&lt;p&gt;&#xd;
5-
Coordinates the build of a Scala distribution based on artifacts on maven (built by scala-release-2.11.x).&#xd;
6-
Downstream jobs: scala-release-2.11.x-[unix|windows|scala-lang].&#xd;
7-
&lt;p&gt;&#xd;
8-
Nightly downloads go to http://www.scala-lang.org/files/archive/nightly/2.11.x/ &lt;br&gt;&#xd;
3+
<description>Build, package and stage a Scala release. TODO
4+
Nightly downloads go to http://www.scala-lang.org/files/archive/nightly/<%=@version%>/ &lt;br&gt;&#xd;
95
Regular ones to http://www.scala-lang.org/files/archive/</description>
106
<properties>
117
<hudson.model.ParametersDefinitionProperty>
128
<parameterDefinitions>
139
<%= scmUserParam("scala") %>
14-
<%= scmRefParam("2.11.x") %>
10+
<%= scmRefParam(@version) %>
1511
<hudson.model.StringParameterDefinition>
1612
<name>SCALA_VER_BASE</name>
1713
<description>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".</description>
@@ -38,10 +34,10 @@ build.setDisplayName(&quot;Scala distribution ${ver} [${build.number}]&quot;)
3834
if (params.repo_ref) buildParams = params
3935
else buildParams = params + [ &apos;repo_ref&apos; : &quot;v$ver&quot; ]
4036

41-
buildRun = build(buildParams, &quot;scala-release-2.11.x-build&quot;)
37+
buildRun = build(buildParams, &quot;<%=job("integrate/bootstrap")%>&quot;)
4238

4339
upstreamBuild = buildRun.build
44-
// for testing, to avoid re-running the main build: upstreamBuild = jenkins.model.Jenkins.instance.items.find{it.name == &quot;scala-release-2.11.x-build&quot;}.builds[0]
40+
// for testing, to avoid re-running the main build: upstreamBuild = jenkins.model.Jenkins.instance.items.find{it.name == &quot;<%=job("integrate/bootstrap")%>&quot;}.builds[0]
4541
// defines repo_ref, version, sbtDistVersionOverride
4642
upstreamPropsArtifact = upstreamBuild.artifacts.find{it.name == &quot;jenkins.properties&quot;}
4743

@@ -51,13 +47,13 @@ buildVersionProps.load(new java.io.FileInputStream(upstreamPropsArtifact.file))
5147
testParams = buildParams + buildVersionProps
5248

5349
parallel (
54-
{ build(testParams, &quot;scala-release-2.11.x-unix&quot;) },
55-
{ build(testParams, &quot;scala-release-2.11.x-windows&quot;) }
50+
{ build(testParams, &quot;<%=job("release/package/unix")%>&quot;) },
51+
{ build(testParams, &quot;<%=job("release/package/windows")%>&quot;) }
5652
)
5753

58-
build(testParams, &quot;scala-release-2.11.x-smoketest&quot;)
54+
build(testParams, &quot;<%=job("release/smoketest")%>&quot;)
5955

60-
build(testParams, &quot;scala-release-2.11.x-scala-lang&quot;)
56+
build(testParams, &quot;<%=job("release/website/archives")%>&quot;)
6157
</dsl>
6258
<publishers>
6359
<hudson.tasks.Mailer plugin="[email protected]">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<%= githubProject(
44
repoUser: "scala",
55
repoName: "scala-dist",
6-
repoRef: "2.11.x",
7-
description: %{ Run as part of the scala-release-2.11.x-dist flow. <p> Builds and uploads the universal and unix-specific artifacts for a
6+
repoRef: @version,
7+
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
1010
Specify a tag that exists on <a href="https://github.com/scala/scala-dist">scala/scala-dist</a>,<br> and that points to a

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<%= githubProject(
44
repoUser: "scala",
55
repoName: "scala-dist",
6-
repoRef: "2.11.x",
7-
description: %{Run as part of the scala-release-2.11.x-dist flow. <p> Builds and uploads the windows-specific artifacts for a Scala
6+
repoRef: @version,
7+
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
1010
Specify a tag that exists on <a href="https://github.com/scala/scala-dist">scala/scala-dist</a>,<br> and that points to a
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<%= githubProject(
44
repoUser: "scala",
55
repoName: "scala-dist-smoketest",
6-
repoRef: "2.11.x",
7-
description: %{ Run as part of the scala-release-2.11.x-dist flow. <br/> It runs the program in
6+
repoRef: @version,
7+
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
1010
http://downloads.typesafe.com/scala/$version/index.html and makes sure the bundled scripts work.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
<%= githubProject(
44
repoUser: "scala",
55
repoName: "scala-dist",
6-
repoRef: "2.11.x",
7-
description: %{ <H1>Run as part of the scala-release-2.11.x-dist flow.</H1>
8-
<p>It downloads the archives for a Scala release
6+
repoRef: @version,
7+
description: "<H1>Run as part of the #{job("release/main")} flow.</H1>" +
8+
%{<p>It downloads the archives for a Scala release
99
from http://downloads.typesafe.com/scala/$version/index.html and
1010
re-organizes them into the right hierarchy for scala-lang.org/files/archive.</p>
1111
<p>Also expands api docs for library, reflect, compiler and other modules
12-
to http://www.scala-lang.org/api/2.11.x/$module (it expands under api/$version
13-
and updates the api/2.11.x symlink to point there).</p>
12+
to http://www.scala-lang.org/api/2.11.x/$module (it expands under api/$version).</p>
1413
<p>When version ends in -nightly, the root for the expansion process
1514
is http://www.scala-lang.org/files/archive/nightly/2.11.x/
1615
instead of http://www.scala-lang.org/files/archive/</p>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project>
3+
<%= githubProject(
4+
repoUser: "scala",
5+
repoName: "scala-dist",
6+
repoRef: @version,
7+
description: "Update scala-lang's api/#{@version} symlink to point to api/$version",
8+
nodeRestriction: "publish",
9+
params: [
10+
{:name => "version", :desc => "The version to be shown for the current API docs."}
11+
])
12+
%>
13+
<builders><%= scriptBuild %></builders>
14+
</project>

templates/default/scala-release-2.11.x/scala-release-2.11.x-scala-lang-update-current.xml.erb

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)