HBASE-20388 nightly tests running on a feature branch should only comment on that feature branch's jira
Signed-off-by: Mike Drob <mdrob@apache.org>
This commit is contained in:
parent
00fca5a4c9
commit
f4a39043e2
|
@ -528,8 +528,14 @@ curl -L -o personality.sh "${env.PROJECT_PERSONALITY}"
|
||||||
echo "[INFO] Comment:"
|
echo "[INFO] Comment:"
|
||||||
echo comment
|
echo comment
|
||||||
echo ""
|
echo ""
|
||||||
echo "[INFO] There are ${currentBuild.changeSets.size()} change sets."
|
echo "[DEBUG] checking to see if feature branch"
|
||||||
getJirasToComment(currentBuild).each { currentIssue ->
|
def jiras = getJirasToComment(env.BRANCH_NAME, [])
|
||||||
|
if (jiras.isEmpty()) {
|
||||||
|
echo "[DEBUG] non-feature branch, checking change messages for jira keys."
|
||||||
|
echo "[INFO] There are ${currentBuild.changeSets.size()} change sets."
|
||||||
|
jiras = getJirasToCommentFromChangesets(currentBuild)
|
||||||
|
}
|
||||||
|
jiras.each { currentIssue ->
|
||||||
jiraComment issueKey: currentIssue, body: comment
|
jiraComment issueKey: currentIssue, body: comment
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
@ -542,7 +548,7 @@ curl -L -o personality.sh "${env.PROJECT_PERSONALITY}"
|
||||||
}
|
}
|
||||||
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
|
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
|
||||||
@NonCPS
|
@NonCPS
|
||||||
List<String> getJirasToComment(RunWrapper thisBuild) {
|
List<String> getJirasToCommentFromChangesets(RunWrapper thisBuild) {
|
||||||
def seenJiras = []
|
def seenJiras = []
|
||||||
thisBuild.changeSets.each { cs ->
|
thisBuild.changeSets.each { cs ->
|
||||||
cs.getItems().each { change ->
|
cs.getItems().each { change ->
|
||||||
|
@ -552,16 +558,21 @@ List<String> getJirasToComment(RunWrapper thisBuild) {
|
||||||
echo " ${change.commitId}"
|
echo " ${change.commitId}"
|
||||||
echo " ${change.author}"
|
echo " ${change.author}"
|
||||||
echo ""
|
echo ""
|
||||||
msg.eachMatch("HBASE-[0-9]+") { currentIssue ->
|
seenJiras = getJirasToComment(msg, seenJiras)
|
||||||
echo "[DEBUG] found jira key: ${currentIssue}"
|
|
||||||
if (currentIssue in seenJiras) {
|
|
||||||
echo "[DEBUG] already commented on ${currentIssue}."
|
|
||||||
} else {
|
|
||||||
echo "[INFO] commenting on ${currentIssue}."
|
|
||||||
seenJiras << currentIssue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return seenJiras
|
return seenJiras
|
||||||
}
|
}
|
||||||
|
@NonCPS
|
||||||
|
List<String> getJirasToComment(CharSequence source, List<String> seen) {
|
||||||
|
source.eachMatch("HBASE-[0-9]+") { currentIssue ->
|
||||||
|
echo "[DEBUG] found jira key: ${currentIssue}"
|
||||||
|
if (currentIssue in seen) {
|
||||||
|
echo "[DEBUG] already commented on ${currentIssue}."
|
||||||
|
} else {
|
||||||
|
echo "[INFO] commenting on ${currentIssue}."
|
||||||
|
seen << currentIssue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return seen
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue