Skip to content

Commit 45816c8

Browse files
authored
Merge pull request #223 from lrytz/bootstrap
Allow jenkins jobs to use an external script
2 parents e342fa9 + caf5545 commit 45816c8

File tree

9 files changed

+99
-13
lines changed

9 files changed

+99
-13
lines changed

attributes/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
default['repos']['private']['realm'] = "Artifactory Realm"
99
default['repos']['private']['host'] = scalaCiHost
1010
default['repos']['private']['pr-snap'] = "https://#{scalaCiHost}/artifactory/scala-pr-validation-snapshots/"
11-
default['repos']['private']['release-temp'] = "https://#{scalaCiHost}/artifactory/scala-release-temp/"
11+
default['repos']['private']['integration'] = "https://#{scalaCiHost}/artifactory/scala-integration/"
1212

1313
default['repos']['caching-proxy']['central']['mirrorOf'] = "central" # TODO: add ",sonatype.release,sonatype.snapshot"
1414
default['repos']['caching-proxy']['central']['url'] = "https://#{scalaCiHost}/artifactory/central/"

attributes/worker.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
default['sbt']['version'] = "0.13.12"
1+
default['sbt']['version'] = "0.13.13"
22

33
workerJavaOpts = "-Dfile.encoding=UTF-8 -server -XX:+AggressiveOpts -XX:+UseParNewGC -Xmx2G -Xss1M -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=128M -Dpartest.threads=4"
44

@@ -51,7 +51,7 @@
5151
default["jenkinsHomes"][jenkinsHome]["env"]['ANT_OPTS'] = "#{workerJavaOpts} #{jvmDirOptions}"
5252
default["jenkinsHomes"][jenkinsHome]["env"]['MAVEN_OPTS'] = "#{workerJavaOpts} #{jvmDirOptions}"
5353
default["jenkinsHomes"][jenkinsHome]["env"]['prRepoUrl'] = node['repos']['private']['pr-snap']
54-
default["jenkinsHomes"][jenkinsHome]["env"]['releaseTempRepoUrl'] = node['repos']['private']['release-temp']
54+
default["jenkinsHomes"][jenkinsHome]["env"]['integrationRepoUrl'] = node['repos']['private']['integration']
5555
default["jenkinsHomes"][jenkinsHome]["env"]['PATH'] = "/bin:/usr/bin:#{jvmBin}:#{gitBin}:#{chocoBin}"
5656
default["jenkinsHomes"][jenkinsHome]["env"]['sbtLauncher'] = node['sbt']['launcher_path']
5757
default["jenkinsHomes"][jenkinsHome]["env"]['WIX'] = node['wix']['home']
@@ -98,7 +98,7 @@
9898
default["jenkinsHomes"][jenkinsHome]["env"]['ANT_OPTS'] = workerJavaOpts
9999
default["jenkinsHomes"][jenkinsHome]["env"]['MAVEN_OPTS'] = workerJavaOpts
100100
default["jenkinsHomes"][jenkinsHome]["env"]['prRepoUrl'] = node['repos']['private']['pr-snap']
101-
default["jenkinsHomes"][jenkinsHome]["env"]['releaseTempRepoUrl'] = node['repos']['private']['release-temp']
101+
default["jenkinsHomes"][jenkinsHome]["env"]['integrationRepoUrl'] = node['repos']['private']['integration']
102102
default["jenkinsHomes"][jenkinsHome]["env"]['sbtLauncher'] = node['sbt']['launcher_path']
103103
default["jenkinsHomes"][jenkinsHome]["env"]['sshCharaArgs'] = '("[email protected]" "-i" "/home/jenkins/.ssh/for_chara")'
104104
default["jenkinsHomes"][jenkinsHome]["env"]['sbtCmd'] = File.join(node['sbt-extras']['setup_dir'], node['sbt-extras']['script_name']) # sbt-extras

doc/genesis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ The jenkins token for scabot has to be configured manually:
394394

395395
- Set admin password.
396396
- create repos (TODO: automate)
397-
- Create scala-ci user that can push to scala-release-temp and scala-pr-validation-snapshots,
397+
- Create scala-ci user that can push to scala-integration and scala-pr-validation-snapshots,
398398
- coordinate scala-ci credentials with jenkins via
399399
```
400400
knife vault update worker-publish private-repo -J private-repo.json
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
3+
baseDir=${WORKSPACE-`pwd`}
4+
scriptsDir="$baseDir/scripts"
5+
. $scriptsDir/common
6+
7+
cd $baseDir
8+
9+
function containsCommit(){
10+
local mb=$(git merge-base $1 HEAD 2> /dev/null)
11+
[[ $1 != "" && $mb == $1 ]]
12+
}
13+
14+
rNewVersionFormat212=18b8f932928bbc440d68babd1270c0bd5406d4fd
15+
rNewVersionFormat211=not-yet-backported
16+
function fNewVersionFormat(){
17+
source $scriptsDir/jobs/integrate/bootstrap
18+
}
19+
20+
function setNewScalaVersionStyle(){
21+
publishToSonatype="no"
22+
23+
# change to use `generateBuildCharacterPropertiesFile` to get the scala version
24+
local useBuildCharacter=e2b6c7b608b82fca5343f6d09236c2b48b5d824d
25+
if containsCommit $useBuildCharacter; then
26+
$SBT_CMD 'set baseVersionSuffix in Global := "UNUSED-SUFFIX"' generateBuildCharacterPropertiesFile
27+
parseScalaProperties "buildcharacter.properties"
28+
SCALA_VER_BASE=$maven_version_base
29+
else
30+
parseScalaProperties "build.number"
31+
SCALA_VER_BASE="$version_major.$version_minor.$version_patch"
32+
fi
33+
34+
local shaSuffix=$(git rev-parse HEAD | cut -c1-7)
35+
local cross="bin"
36+
if [[ $SCALA_VER_BASE =~ ^.*\.0$ ]]; then
37+
cross="pre"
38+
fi
39+
SCALA_VER_SUFFIX="-$cross-$shaSuffix"
40+
}
41+
42+
# - changed default repo from "scala-release-temp" to "scala-integration"
43+
# - renamed $releaseTempRepoUrl to $integrationRepoUrl
44+
rIntegrationRepo212=9b6820f259a7583671ae910a63d6e6d95a5e7cdf
45+
rIntegrationRepo211=not-yet-backported
46+
function fIntegrationRepo(){
47+
setNewScalaVersionStyle
48+
source $scriptsDir/jobs/integrate/bootstrap
49+
}
50+
51+
# - introducded the $releaseTempRepoUrl variable
52+
rReleaseTempVarName=706d68f863ebffb0f63811afe0835c5f975ba225
53+
function fReleaseTempVarName(){
54+
setNewScalaVersionStyle
55+
releaseTempRepoUrl="https://scala-ci.typesafe.com/artifactory/scala-integration/"
56+
source $scriptsDir/jobs/integrate/bootstrap
57+
}
58+
59+
# TODO: support older revisions
60+
61+
# main
62+
if containsCommit $rNewVersionFormat212 || containsCommit $rNewVersionFormat211; then
63+
fNewVersionFormat
64+
65+
if containsCommit $rIntegrationRepo212 || containsCommit $rIntegrationRepo211; then
66+
fIntegrationRepo
67+
68+
else if containsCommit $rReleaseTempVarName; then
69+
fReleaseTempVarName
70+
71+
else
72+
echo "Cannot build revision $(git rev-parse HEAD)"
73+
exit 42
74+
75+
fi

libraries/job_blurbs.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def githubProject(options = {})
123123
jvmSelectScript=jvmSelect
124124
end
125125

126+
useExternalScript = options.fetch(:useExternalScript, false)
127+
mainScript = useExternalScript ? externalScript : "source scripts/#{@scriptName}"
128+
126129
restriction =
127130
"""<assignedNode>%{nodes}</assignedNode>
128131
<canRoam>false</canRoam>""".gsub(/ /, '')
@@ -139,7 +142,7 @@ def env(name)
139142
<concurrentBuild>#{concurrent}</concurrentBuild>
140143
<builders>
141144
#{groovySysScript(buildNameScript)}
142-
#{scriptBuild(jvmSelectScript)}
145+
#{scriptBuild(jvmSelectScript, mainScript)}
143146
</builders>
144147
<buildWrappers>
145148
<hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="[email protected]">
@@ -204,12 +207,19 @@ def jvmSelect
204207
EOH
205208
end
206209

207-
def scriptBuild(setup)
210+
def externalScript
211+
<<-EOH.gsub(/^ /, '')
212+
wget https://raw.githubusercontent.com/scala/scala-jenkins-infra/master/externalScripts/#{@scriptName} -O externalScript
213+
source externalScript
214+
EOH
215+
end
216+
217+
def scriptBuild(setup, mainScript)
208218
<<-EOH.gsub(/^ /, '')
209219
<hudson.tasks.Shell>
210220
<command>#!/bin/bash -ex
211221
#{setup}
212-
source scripts/#{@scriptName}
222+
#{mainScript}
213223
</command>
214224
</hudson.tasks.Shell>
215225
EOH

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
buildTimeoutMinutes: 200,
1919
jvmVersion: @jvmVersionForBranch,
2020
jvmFlavor: @jvmFlavorForBranch,
21+
useExternalScript: true,
2122
params: [
2223
{:name => "SCALA_VER_BASE",
23-
:desc => "Specifying this parameter will cause a release to be built. If it&apos;s empty (and HEAD does not have a tag that parses as a version), a -nightly release is built."},
24+
:desc => "Specifying this parameter will cause a release to be built. If it&apos;s empty (and HEAD does not have a tag that parses as a version), an integration release is built."},
2425
{:name => "SCALA_VER_SUFFIX",
2526
:desc => "Empty for a final release, otherwise, e.g., -RC1 for the first RC or -M3 for the third milestone. (Will be parsed from the tag on SCALA_REF, if any.)"},
2627
{:name => "SCALA_BINARY_VER",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{:name => "publishToSonatype", :desc => "[For bootstrap] Set to anything but &quot;yes&quot; to avoid publishing to sonatype. Otherwise, release builds (tagged or SCALA_VER_BASE defined) will be published."},
1212
{:name => "testStability", :desc => "[For bootstrap] To avoid running the stability test, set to e.g., `no`", :default => "yes"},
1313
{:name => "moduleVersioning", :desc => "[For bootstrap] Set to anything but &quot;versions.properties&quot; to build the latest HEAD for all modules."},
14-
{:name => "SCALA_VER_BASE", :desc => "[For bootstrap] Specifying this parameter will cause a release to be built. If it&apos;s empty (and HEAD does not have a tag that parses as a version), a -nightly release is built."},
14+
{:name => "SCALA_VER_BASE", :desc => "[For bootstrap] Specifying this parameter will cause a release to be built. If it&apos;s empty (and HEAD does not have a tag that parses as a version), an integration release is built."},
1515
{:name => "SCALA_VER_SUFFIX", :desc => "[For bootstrap] Empty for a final release, otherwise, e.g., -RC1 for the first RC or -M3 for the third milestone. (Will be parsed from the tag on SCALA_REF, if any.)"},
1616
{:name => "SCALA_BINARY_VER", :desc => "[For bootstrap] For binary compatible releases (such as 2.11.0 and 2.11.1), the short binary version (e.g. 2.11). Otherwise, the full Scala version."},
1717
{:name => "SCALA_FULL_VER", :desc => "[For bootstrap] For non-snapshot releases, the scala version, otherwise the closest scala version that&apos;s a valid binary version. Used to cross-version the scala continuations plugin."},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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
1212
to http://www.scala-lang.org/api/2.11.x/$module (it expands under api/$version).</p>
13-
<p>When version ends in -nightly, the root for the expansion process
13+
<p>When version ends in `(bin|pre)-sha`, the root for the expansion process
1414
is http://www.scala-lang.org/files/archive/nightly/2.11.x/
1515
instead of http://www.scala-lang.org/files/archive/</p>
1616
}.gsub(/^ {4}/, ''),

templates/default/m2-settings-public-jobs.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<url><%=node['repos']['private']['pr-snap']%></url>
2727
</repository>
2828
<repository>
29-
<id>scala-release-temp</id>
29+
<id>scala-integration</id>
3030
<name>Scala Release snapshots</name>
31-
<url><%=node['repos']['private']['release-temp']%></url>
31+
<url><%=node['repos']['private']['integration']%></url>
3232
</repository>
3333
</repositories>
3434
</profile>

0 commit comments

Comments
 (0)