Skip to content

Commit fc2872f

Browse files
committed
pr validation beginning
1 parent 41980f8 commit fc2872f

File tree

9 files changed

+143
-45
lines changed

9 files changed

+143
-45
lines changed

libraries/job_blurbs.rb

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
module ScalaJenkinsInfra
44
module JobBlurbs
5+
def properties(repoUser, repoName, repoRef, params)
6+
stringPar =
7+
"""
8+
<hudson.model.StringParameterDefinition>
9+
<name>%{name}</name>
10+
<description>%{desc}</description>
11+
<defaultValue>%{default}</defaultValue>
12+
</hudson.model.StringParameterDefinition>""".gsub(/ /, '')
13+
14+
paramDefaults = {:default => nil}
15+
16+
"""<properties>
17+
<hudson.model.ParametersDefinitionProperty>
18+
<parameterDefinitions>
19+
#{scmParams(repoUser, repoName, repoRef)}
20+
#{params.map { |param| stringPar % paramDefaults.merge(param) }.join("\n")}
21+
</parameterDefinitions>
22+
</hudson.model.ParametersDefinitionProperty>
23+
</properties>"""
24+
end
25+
526
def githubProject(options = {})
627
# chef's still stuck on ruby 1.9 (on our amazon linux)
728
repoUser = options[:repoUser]
@@ -11,31 +32,17 @@ def githubProject(options = {})
1132
nodeRestriction = options.fetch(:nodeRestriction, nil)
1233
params = options.fetch(:params, [])
1334

14-
stringPar =
15-
"""<hudson.model.StringParameterDefinition>
16-
<name>%{name}</name>
17-
<description>%{desc}</description>
18-
<defaultValue>%{default}</defaultValue>
19-
</hudson.model.StringParameterDefinition>""".gsub(/ /, '')
20-
21-
paramDefaults = {:default => nil}
22-
2335
restriction =
2436
"""<assignedNode>%{nodes}</assignedNode>
2537
<canRoam>false</canRoam>""".gsub(/ /, '')
2638

27-
def env(name) = "${ENV,var=&quot;#{name}&quot;}"
39+
def env(name)
40+
"${ENV,var=&quot;#{name}&quot;}"
41+
end
2842

2943
<<-EOX
3044
<description>#{CGI.escapeHTML(description)}</description>
31-
<properties>
32-
<hudson.model.ParametersDefinitionProperty>
33-
<parameterDefinitions>
34-
#{scmParams(repoUser, repoName, repoRef)}
35-
#{params.map { |param| stringPar % paramDefaults.merge(param) }.join("\n")}
36-
</parameterDefinitions>
37-
</hudson.model.ParametersDefinitionProperty>
38-
</properties>
45+
#{properties(repoUser, repoName, repoRef, params)}
3946
<org.jenkinsci.plugins.buildnamesetter.BuildNameSetter plugin="[email protected]">
4047
<template>[${BUILD_NUMBER}] of #{env(repoUser)}/#{env(repoName)}\##{env(repoRef)}</template>
4148
</org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>

recipes/_master-config-jobs.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ def templDesc(version, path)
4040
end
4141
end
4242

43+
# TODO: jobs in integrate/ (test IDE integration, matrix, core-community)
44+
# if all integration builds succeed, release can be done
45+
# matrix:
46+
# - buildArgs:
47+
# - rangepos
48+
# - os:
49+
# - windows
50+
# - linux
51+
# - jdk:
52+
# - 7
53+
# - 8
54+
# - 9
55+
# core-community: sbt, ensime, modules,...
56+
4357
# create scala-$version-$jobName for every template under jobs/
4458
%w{ 2.11.x }.each do | version |
4559
node.run_context.cookbook_collection["scala-jenkins-infra"].manifest[:templates]

recipes/_master-config-workers.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
host worker.ipaddress
3737
credentials credentialsMap[workerConfig["jenkinsUser"]] # must use id (groovy script fails otherwise)
3838

39-
max_num_retries 5 # how often to retry when the SSH connection is refused during initial connect
39+
# TODO: make retrying more robust
40+
max_num_retries 10 # how often to retry when the SSH connection is refused during initial connect
4041
retry_wait_time 60 # seconds between retries
4142

4243
remote_fs jenkinsHome.dup
@@ -55,7 +56,7 @@
5556

5657
environment((eval node["master"]["env"]).call(node).merge((eval workerConfig["env"]).call(worker)))
5758

58-
action [:create, :connect, :online]
59+
action [:create, :connect, :online] # TODO: allow connect/online to fail (workers may be offline)
5960
end
6061
end
6162
end

recipes/master-config.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,30 @@
2626
end
2727
end
2828

29+
%w(ssh-credentials build-name-setter cygpath job-dsl build-flow-plugin rebuild greenballs build-timeout copyartifact email-ext slack throttle-concurrents dashboard-view parameterized-trigger).each do |plugin|
30+
plugin, version = plugin.split('=') # in case we decide to pin versions later
31+
jenkins_plugin plugin
32+
end
33+
34+
jenkins_plugin "ec2-start-stop" do
35+
source node['master']['ec2-start-stop']['url']
36+
# doesn't support checksum
37+
end
38+
39+
# restart jenkins (TODO: wait for it to come back up, so we can continue automatically with next recipes; until then, manually)
40+
# Theory for observed failure: github-oauth plugin needs restart
41+
# next steps: add scala-jenkins-infra::master-auth-github, and scala-jenkins-infra::master-workers (once they are up) to run_list
42+
jenkins_plugin "github-oauth" do
43+
# To be sure, do safe restart (see subscribes below), since we're running chef every thirty minutes
44+
end
45+
46+
jenkins_command 'safe-restart' do
47+
action :nothing
48+
subscribes :execute, 'jenkins_plugin[github-oauth]', :delayed
49+
end
50+
2951
include_recipe 'scala-jenkins-infra::_master-config-auth-github'
3052

31-
include_recipe 'scala-jenkins-infra::_master-config-workers'
53+
include_recipe 'scala-jenkins-infra::_master-config-jobs'
3254

33-
include_recipe 'scala-jenkins-infra::_master-config-jobs'
55+
include_recipe 'scala-jenkins-infra::_master-config-workers'

recipes/master-init.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,3 @@
4343

4444
# nginx reverse proxy setup, in concert with JenkinsLocationConfiguration above
4545
include_recipe 'scala-jenkins-infra::_master-init-proxy'
46-
47-
%w(ssh-credentials build-name-setter cygpath job-dsl build-flow-plugin rebuild greenballs build-timeout copyartifact email-ext slack throttle-concurrents dashboard-view parameterized-trigger).each do |plugin|
48-
plugin, version = plugin.split('=') # in case we decide to pin versions later
49-
jenkins_plugin plugin
50-
end
51-
52-
jenkins_plugin "ec2-start-stop" do
53-
source node['master']['ec2-start-stop']['url']
54-
# doesn't support checksum
55-
end
56-
57-
# restart jenkins (TODO: wait for it to come back up, so we can continue automatically with next recipes; until then, manually)
58-
# Theory for observed failure: github-oauth plugin needs restart
59-
# next steps: add scala-jenkins-infra::master-auth-github, and scala-jenkins-infra::master-workers (once they are up) to run_list
60-
jenkins_plugin "github-oauth" do
61-
# To be sure, do safe restart (see subscribes below), since we're running chef every thirty minutes
62-
end
63-
64-
jenkins_command 'safe-restart' do
65-
action :nothing
66-
subscribes :execute, 'jenkins_plugin[github-oauth]', :immediately
67-
end

recipes/worker-init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# All rights reserved - Do Not Redistribute
88
#
9-
include_recipe 'chef-client::service'
9+
include_recipe 'chef-client::service' # TODO: it seems chef's not run on boot on windows?
1010

1111
chef_gem "chef-vault"
1212

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<com.cloudbees.plugins.flow.BuildFlow plugin="[email protected]">
3+
<description>PR validation -- called for every commit in every PR</description>
4+
<%= properties("scala", "scala", @version,
5+
[{:name => "prDryRun",
6+
:desc => ""}]) %>
7+
<scm class="hudson.scm.NullSCM"/>
8+
<canRoam>true</canRoam>
9+
<dsl>
10+
buildRun = build(params, &quot;<%=job("validate/publish-core")%>&quot;)
11+
12+
upstreamBuild = buildRun.build
13+
// for testing, to avoid re-running the main build: upstreamBuild = jenkins.model.Jenkins.instance.items.find{it.name == &quot;<%=job("validate/publish-core")%>&quot;}.builds[0]
14+
// defines maven_version_number
15+
upstreamPropsArtifact = upstreamBuild.artifacts.find{it.name == &quot;jenkins.properties&quot;}
16+
17+
buildVersionProps = new java.util.Properties()
18+
buildVersionProps.load(new java.io.FileInputStream(upstreamPropsArtifact.file))
19+
20+
testParams = params + buildVersionProps
21+
22+
build(testParams, &quot;<%=job("validate/test")%>&quot;)
23+
24+
//parallel (
25+
// { build(testParams, &quot;<%=job("validate/test")%>&quot;) },
26+
// { build(testParams, &quot;<%=job("validate/test-bla")%>&quot;) }
27+
//)
28+
</dsl>
29+
<publishers>
30+
<hudson.tasks.Mailer plugin="[email protected]">
31+
<recipients>[email protected]</recipients>
32+
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
33+
<sendToIndividuals>false</sendToIndividuals>
34+
</hudson.tasks.Mailer>
35+
</publishers>
36+
</com.cloudbees.plugins.flow.BuildFlow>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project>
3+
<%= githubProject(
4+
repoUser: "scala",
5+
repoName: "scala",
6+
repoRef: @version,
7+
description: "PR validation: publish core",
8+
nodeRestriction: "public",
9+
params: [
10+
{:name => "prDryRun", :desc => "Set to 'yep' to try out the jenkins flow."},
11+
{:name => "antBuildArgs", :desc => "TODO"}
12+
])
13+
%>
14+
<builders><%= scriptBuild %></builders>
15+
<publishers>
16+
<hudson.tasks.ArtifactArchiver>
17+
<artifacts>jenkins.properties</artifacts>
18+
<allowEmptyArchive>false</allowEmptyArchive>
19+
<onlyIfSuccessful>false</onlyIfSuccessful>
20+
<fingerprint>false</fingerprint>
21+
<defaultExcludes>true</defaultExcludes>
22+
</hudson.tasks.ArtifactArchiver>
23+
</publishers>
24+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project>
3+
<%= githubProject(
4+
repoUser: "scala",
5+
repoName: "scala",
6+
repoRef: @version,
7+
description: "PR validation: test suite",
8+
nodeRestriction: "public",
9+
params: [
10+
{:name => "maven_version_number", :desc => "Set by main build flow."},
11+
{:name => "testExtraArgs", :desc => "TODO"},
12+
{:name => "testTarget", :desc => "TODO"}
13+
])
14+
%>
15+
<builders><%= scriptBuild %></builders>
16+
</project>

0 commit comments

Comments
 (0)