This is an automated email from the ASF dual-hosted git repository.
tzimanyi pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-pipelines.git
The following commit(s) were added to refs/heads/main by this push:
new fea26e17 kie-issues#592: fix postComment for current plugin (#1099)
fea26e17 is described below
commit fea26e17fc0566ef5858365360df43c4fbd2b0cd
Author: Jan Stastny <[email protected]>
AuthorDate: Mon Oct 2 12:41:38 2023 +0200
kie-issues#592: fix postComment for current plugin (#1099)
Co-authored-by: jstastny-cz <[email protected]>
---
dsl/scripts/pr_check.groovy | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dsl/scripts/pr_check.groovy b/dsl/scripts/pr_check.groovy
index 6be21050..b5bee969 100644
--- a/dsl/scripts/pr_check.groovy
+++ b/dsl/scripts/pr_check.groovy
@@ -31,7 +31,10 @@ void launchInDocker(String builderImage) {
echo "Got build result ${currentBuild.currentResult}"
if (currentBuild.currentResult != 'SUCCESS') {
// TODO ci token as env ?
- pullrequest.postComment(util.getMarkdownTestSummary('PR',
getReproducer(true), "${BUILD_URL}", 'GITHUB'), "kie-ci3-token")
+ postComment(
+ util.getMarkdownTestSummary('PR', getReproducer(true),
"${BUILD_URL}", 'GITHUB'),
+ 'kie-ci3-token'
+ )
}
}
}
@@ -133,4 +136,23 @@ ${reproducer}
}
}
+/**
+* This method add a comment to current PR (for Github Branch Source plugin)
+*/
+void postComment(String commentText, String githubTokenCredsId =
"kie-ci1-token") {
+ if (!CHANGE_ID) {
+ error "Pull Request Id variable (CHANGE_ID) is not set. Are you sure
you are running with Github Branch Source plugin ?"
+ }
+ String filename = "${util.generateHash(10)}.build.summary"
+ def jsonComment = [
+ body : commentText
+ ]
+ writeJSON(json: jsonComment, file: filename)
+ sh "cat ${filename}"
+ withCredentials([string(credentialsId: githubTokenCredsId, variable:
'GITHUB_TOKEN')]) {
+ sh "curl -s -H \"Authorization: token ${GITHUB_TOKEN}\" -X POST -d
'@${filename}'
\"https://api.github.com/repos/${BUILDCHAIN_PROJECT}/issues/${CHANGE_ID}/comments\""
+ }
+ sh "rm ${filename}"
+}
+
return this
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]