Skip to content

Instantly share code, notes, and snippets.

@ysb33r
Last active December 19, 2015 01:19
Show Gist options
  • Save ysb33r/5875095 to your computer and use it in GitHub Desktop.
Save ysb33r/5875095 to your computer and use it in GitHub Desktop.
An example of a more complex build flow in Jenkins.
def partitions=6
def testResults
def buildResult
def staticAnalysisResult
def smokeTestResult
def performanceResult
def buildFlow= { buildResult= build( 'BUILDER' ) }
def performanceFlow= { performanceResult = build('PERFORMANCE')}
def staticAnalysisFlow= { staticAnalysisResult= build( 'STATIC_ANALYSIS' ) }
def smokeTestFlow= {
smokeTestResult= build (
'TEST_PARTITION',
SOURCE_JOB : 'BUILDER',
SOURCE_BUILD_NUMBER : buildResult.build.number,
PARTITON : "smoke"
)
}
def testFlow= {
TestResults= parallel(
(1..partitions).collect { ctr ->
return {
ignore(UNSTABLE) {
build (
'TEST_PARTITION',
SOURCE_JOB : 'BUILDER',
SOURCE_BUILD_NUMBER : buildResult.build.number,
PARTITION : "${ctr}/${partitions}"
)
}
}
}
)
}
def functionalTestFlow = { [ smokeTestFlow, testFlow ].each {it()} }
def mainFlow = {
[ buildFlow,
{ parallel( functionalTestFlow, performanceFlow ) }
].each { it() }
}
parallel (
mainFlow,
staticAnalysisFlow
)
def testBuildNumbers= [smokeTestResult.build.number]
if(testResults) {
testBuildNumbers+= testResults.collect { c ->
c.lastBuild.build.number
}
}
build (
'COLLECTOR',
TEST_JOB_NAME : 'TEST_PARTITION',
TEST_BUILD_NUMBERS : testBuildNumbers.join(','),
SA_JOB_NAME : staticAnalysisResult.name,
SA_BUILD_NUMBER : staticAnalysisResult.build.number,
BUILDER_JOB_NAME : buildResult.name,
BUILDER_BUILD_NUMBER : buildResult.build.number,
PERF_JOB_NAME : performanceResult.name,
PERF_BUILD_NUMBER : performanceResult.build.number
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment