Last active
August 29, 2015 14:13
-
-
Save dirk-thomas/9bbd47397e48ef3ceef8 to your computer and use it in GitHub Desktop.
Create "leaf" job with a single upstream dependency "before_leaf" where "before_leaf" has many (in this case 40) upstream dependencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
job_prefix = 'jenkins21605_caseA_' | |
println 'Deleting jobs from previous tests...' | |
for (p in Jenkins.instance.allItems) { | |
if (!p.name.startsWith(job_prefix)) continue | |
println '- ' + p.name | |
p.delete() | |
} | |
println '' | |
def createProject(job_name, upstream_names) { | |
job_config_template = ''' | |
<project> | |
<actions/> | |
<description></description> | |
<keepDependencies>false</keepDependencies> | |
<properties/> | |
<scm class="hudson.scm.NullSCM"/> | |
<assignedNode>master</assignedNode> | |
<canRoam>false</canRoam> | |
<disabled>false</disabled> | |
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> | |
<blockBuildWhenUpstreamBuilding>true</blockBuildWhenUpstreamBuilding> | |
<triggers> | |
<jenkins.triggers.ReverseBuildTrigger> | |
<spec></spec> | |
<upstreamProjects>%1$s</upstreamProjects> | |
<threshold> | |
<name>UNSTABLE</name> | |
<ordinal>1</ordinal> | |
<color>YELLOW</color> | |
<completeBuild>true</completeBuild> | |
</threshold> | |
</jenkins.triggers.ReverseBuildTrigger> | |
</triggers> | |
<concurrentBuild>false</concurrentBuild> | |
<builders> | |
<hudson.plugins.groovy.SystemGroovy plugin="[email protected]"> | |
<scriptSource class="hudson.plugins.groovy.StringScriptSource"> | |
<command>println 'dummy build step'</command> | |
</scriptSource> | |
<bindings></bindings> | |
<classpath></classpath> | |
</hudson.plugins.groovy.SystemGroovy> | |
</builders> | |
<publishers/> | |
<buildWrappers/> | |
</project> | |
''' | |
upstream_projects = '' | |
for (upstream_name in upstream_names) { | |
upstream_projects += job_prefix + upstream_name + ',' | |
} | |
job_config = sprintf(job_config_template, upstream_projects) | |
stream = new StringBufferInputStream(job_config) | |
println '- ' + job_prefix + job_name | |
Jenkins.instance.createProjectFromXML(job_prefix + job_name, stream) | |
} | |
def createProjects(parent_name, count) { | |
range = 1..count | |
for (i in range) { | |
createProject(parent_name + String.format("%0" + 2 + "d", i), [parent_name]) | |
} | |
} | |
println 'Creating new job hierarchy...' | |
createProject('', []) | |
all_parents = [] | |
range = 1..40 | |
parent = '' | |
for (i in range) { | |
name = String.format("%0" + 2 + "d", i) | |
createProject(name, [parent]) | |
parent = name | |
all_parents += [parent] | |
println all_parents | |
} | |
createProject('before_leaf', all_parents) | |
createProject('leaf', ['before_leaf']) | |
println '' | |
println 'You can create a view to show all test jobs using the regular expression: ' + job_prefix | |
println '' | |
println 'Please trigger the root job: ' + job_prefix | |
println 'And then look at the leaf job: ' + job_prefix + 'leaf' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment