Last active
September 28, 2016 02:30
-
-
Save jdickie/2aa65b19de519078a5f11b553e4c908d to your computer and use it in GitHub Desktop.
From the upstream job we get a nice Config object that can be iterated through to create jobs. Here we're making a job that will SSH into a server and run PHPUnit tests with variables specified within that Config object. If the Config specifies the job being iterated is a 'master' job, then it creates a MultiJob for running all of the tests in t…
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
Config.jobs.each { _job -> | |
switch (_job.type) { | |
case 'job': | |
job(namePrefix + _job.name) { | |
logRotator(CarbonApiProps.num_days_to_keep, CarbonApiProps.num_builds_to_keep, | |
CarbonApiProps.num_artifacts_days, CarbonApiProps.num_artifacts) | |
throttleConcurrentBuilds { | |
categories([carbonThrottleCategory]) | |
} | |
if (serverName && _job.remoteCommand) { | |
steps { | |
/** | |
* Replacing remoteShell with publishOverSsh | |
*/ | |
publishOverSsh { | |
failOnError(failOnError = true) | |
server(serverName) { | |
retry(retries = 1, delay = 10000) | |
verbose(verbose = true) | |
transferSet { | |
execTimeout(600000) | |
execCommand(_job.remoteCommand) | |
} | |
} | |
} | |
} | |
} | |
publishers { | |
allowBrokenBuildClaiming() | |
} | |
if (configuration["NO_TIMEOUTS"] == null || configuration["NO_TIMEOUTS"].toBoolean() == false) { | |
wrappers { | |
// set up no activity timeouts | |
timeout { | |
noActivity(CarbonApiProps.noactivity_secondsToWait) | |
} | |
} | |
} | |
} | |
break; | |
case 'master': | |
def multiJobReadableName = "Carbon API Tests for ${envName} :: Higgins" | |
multiJob(namePrefix + _job.name) { | |
description("Runs all Carbon test jobs for branch " + configuration["GIT_BRANCH"] + | |
"and environment ${testFolderName}\n" + | |
"Last kicked off by: ${configuration["GIT_MESSAGE"]}") | |
displayName(multiJobReadableName) | |
logRotator(numDaysToKeepBuilds, numBuildsToKeep, | |
CarbonApiProps.num_artifacts_days, CarbonApiProps.num_artifacts) | |
steps { | |
shell("echo \"<h1>${configuration["GIT_MESSAGE"]}</h1>\"") | |
phase('Carbon Tests') { | |
_job.jobs.each { _nJob -> | |
def (jobPhase, jobName) = _nJob.tokenize("|") | |
phaseJob(jobName) { | |
killPhaseCondition('NEVER') | |
} | |
} | |
// We never ever stop here either | |
continuationCondition('ALWAYS') | |
} | |
} | |
publishers { | |
// Removed HipChat notifications | |
if (_job.slackChannel) { | |
slackNotifications { | |
projectChannel(_job.slackChannel) | |
teamDomain("nprdigital") | |
notifySuccess() | |
notifyAborted() | |
notifyFailure() | |
notifyRepeatedFailure() | |
notifyUnstable() | |
} | |
} | |
} | |
wrappers { | |
preBuildCleanup { | |
deleteDirectories() | |
} | |
if (!noTimeouts) { | |
// set up no activity timeouts | |
timeout { | |
absolute(CarbonApiProps.absolute_timeout_minutes) | |
} | |
} | |
} | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment