From 65c2064d03050a1b29ccf3a8217112fde85d288f Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Thu, 18 Feb 2021 11:13:50 -0500 Subject: [PATCH 1/2] [CI] Ping assignees on Github PR comments --- vars/githubPr.groovy | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vars/githubPr.groovy b/vars/githubPr.groovy index eead00c082ba..383ee690d5c4 100644 --- a/vars/githubPr.groovy +++ b/vars/githubPr.groovy @@ -235,6 +235,11 @@ def getNextCommentMessage(previousCommentInfo = [:], isFinal = false) { messages << "To update your PR or re-run it, just comment with:\n`@elasticmachine merge upstream`" + def assignees = getAssignees() + if (assignees) { + messages << "cc " + assignees.collect { "@${it}"}.join(" ") + } + info.builds << [ status: status, url: env.BUILD_URL, @@ -329,3 +334,19 @@ def shouldCheckCiMetricSuccess() { return true } + +def getPR() { + withGithubCredentials { + def path = "repos/elastic/kibana/pulls/${env.ghprbPullId}" + return githubApi.get(path) + } +} + +def getAssignees() { + def pr = getPR() + if (!pr) { + return [] + } + + return pr.assignees.collect { it.login } +} From 6893b86d9b147b13766ebea4f63a42ac3df9cfad Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Thu, 18 Feb 2021 11:26:04 -0500 Subject: [PATCH 2/2] Don't fail the comment if assignees can't be fetched for some reason --- vars/githubPr.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vars/githubPr.groovy b/vars/githubPr.groovy index 383ee690d5c4..d024eb7346f8 100644 --- a/vars/githubPr.groovy +++ b/vars/githubPr.groovy @@ -235,9 +235,11 @@ def getNextCommentMessage(previousCommentInfo = [:], isFinal = false) { messages << "To update your PR or re-run it, just comment with:\n`@elasticmachine merge upstream`" - def assignees = getAssignees() - if (assignees) { - messages << "cc " + assignees.collect { "@${it}"}.join(" ") + catchErrors { + def assignees = getAssignees() + if (assignees) { + messages << "cc " + assignees.collect { "@${it}"}.join(" ") + } } info.builds << [