如何在来自 jenkins/jenkinsfile 的 github pullRequest 中发送评论
How send a comment in a github pullRequest from jenkins/jenkinsfile
我使用组织插件构建我的 github 项目的 pullRequest。
在此构建期间,我想将带有项目某些指标的自定义评论发送到 github pullRequest。
我该怎么做?
没关系,我发现:(你需要安装http Request插件)
def SHA1 = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def body="""{
"body": "Nice change",
"commit_id": "$SHA1",
"path": "/",
"position": 0
}"""
httpRequest authentication: '${yourCredential}', httpMode: 'POST', requestBody: body, url: 'https://api.github.com/repos/${yourOrga}/${yourRepo}/issues/${pullRequestNumber}/comments'
不允许发表评论,但详细说明以前的回答:
httpRequest authentication: '${yourCredential}', httpMode: 'POST', requestBody: body, url: 'https://api.github.com/repos/${yourOrga}/${yourRepo}/issues/${pullRequestNumber}/comments'
$yourcredential 是一个名称,应与用户名和密码类型的凭据相匹配。在 github 你应该创建一个令牌并使用它。
在 pullrequest 中,您通常会得到 url (Genericwebhook) 问题,您可以在其中 post 作为 webhook 负载的一部分发表评论。
我使用组织插件构建我的 github 项目的 pullRequest。 在此构建期间,我想将带有项目某些指标的自定义评论发送到 github pullRequest。
我该怎么做?
没关系,我发现:(你需要安装http Request插件)
def SHA1 = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def body="""{
"body": "Nice change",
"commit_id": "$SHA1",
"path": "/",
"position": 0
}"""
httpRequest authentication: '${yourCredential}', httpMode: 'POST', requestBody: body, url: 'https://api.github.com/repos/${yourOrga}/${yourRepo}/issues/${pullRequestNumber}/comments'
不允许发表评论,但详细说明以前的回答:
httpRequest authentication: '${yourCredential}', httpMode: 'POST', requestBody: body, url: 'https://api.github.com/repos/${yourOrga}/${yourRepo}/issues/${pullRequestNumber}/comments'
$yourcredential 是一个名称,应与用户名和密码类型的凭据相匹配。在 github 你应该创建一个令牌并使用它。
在 pullrequest 中,您通常会得到 url (Genericwebhook) 问题,您可以在其中 post 作为 webhook 负载的一部分发表评论。