提交 ca18ff9a 编写于 作者: J Jared Parsons

Factor out the trigger phrase code

Move the trigger phrase generation code into a separate function.  This simplified the code
for adding a standard job.
上级 df01b581
......@@ -137,13 +137,19 @@ static void addPushTrigger(def myJob) {
}
}
static void addPullRequestTrigger(def myJob, String contextName, String opsysName, String triggerKeyword = 'this', Boolean triggerOnly = false) {
// Generates the standard trigger phrases. This is the regex which ends up matching lines like:
// test win32 please
static String generateTriggerPhrase(String jobName, string opsysName, Stringc triggerKeyword = 'this') {
return "(?i).*test\\W+(${jobName.replace('_', '/').substring(7)}|${opsysName}|${triggerKeyword}|${opsysName}\\W+${triggerKeyword}|${triggerKeyword}\\W+${opsysName})\\W+please.*";
}
static void addPullRequestTrigger(def myJob, String jobName, String triggerPhrase, Boolean triggerOnly = false) {
myJob.with {
triggers {
pullRequest {
admin('Microsoft')
useGitHubHooks(true)
triggerPhrase("(?i).*test\\W+(${contextName.replace('_', '/').substring(7)}|${opsysName}|${triggerKeyword}|${opsysName}\\W+${triggerKeyword}|${triggerKeyword}\\W+${opsysName})\\W+please.*")
triggerPhrase(triggerPhrase)
onlyTriggerPhrase(triggerOnly)
autoCloseFailedPullRequests(false)
orgWhitelist('Microsoft')
......@@ -151,7 +157,7 @@ static void addPullRequestTrigger(def myJob, String contextName, String opsysNam
permitAll(true)
extensions {
commitStatus {
context(contextName.replace('_', '/').substring(7))
context(jobName.replace('_', '/').substring(7))
}
}
}
......@@ -159,7 +165,7 @@ static void addPullRequestTrigger(def myJob, String contextName, String opsysNam
}
}
static void addStandardJob(def myJob, String jobName, String branchName, String buildTarget, String opsys) {
static void addStandardJob(def myJob, String jobName, String branchName, String triggerPhrase) {
addLogRotator(myJob)
addWrappers(myJob)
......@@ -168,14 +174,7 @@ static void addStandardJob(def myJob, String jobName, String branchName, String
addArtifactArchiving(myJob, includePattern, excludePattern)
if (branchName == 'prtest') {
switch (buildTarget) {
case 'unit32':
addPullRequestTrigger(myJob, jobName, opsys, "(unit|unit32|unit\\W+32)")
break;
case 'unit64':
addPullRequestTrigger(myJob, jobName, opsys, '(unit|unit64|unit\\W+64)')
break;
}
addPullRequestTrigger(myJob, jobName, triggerPhrase);
addScm(myJob, '${sha1}', '+refs/pull/*:refs/remotes/origin/pr/*')
} else {
addPushTrigger(myJob)
......@@ -203,6 +202,18 @@ def branchNames = []
description('')
}
// Generate the PR trigger phrase for this job.
String triggerKeyword = '';
switch (buildTarget) {
case 'unit32':
triggerKeyword = '(unit|unit32|unit\\W+32)';
break;
case 'unit64':
triggerKeyword = '(unit|unit64|unit\\W+64)';
break;
}
String triggerPhrase = generateTriggerPhrase(jobName, opsys, triggerKeyword);
switch (opsys) {
case 'win':
myJob.with {
......@@ -238,7 +249,7 @@ set TMP=%TEMP%
}
addUnitPublisher(myJob)
addStandardJob(myJob, jobName, branchName, buildTarget, opsys)
addStandardJob(myJob, jobName, branchName, triggerPhrase);
}
}
}
......@@ -262,7 +273,7 @@ set TMP=%TEMP%
}
addConcurrentBuild(determinismJob, null)
addStandardJob(determinismJob, determinismJobName, branchName, "unit32", "win")
addStandardJob(determinismJob, determinismJobName, branchName, '');
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册