简体   繁体   English

Jenkins Gerrit-Trigger在成功运行作业后未报告+1

[英]Jenkins Gerrit-Trigger not reporting +1 verified after successful job run

I'm currently attempting to issue a "+1 Verified" using the Jenkins Gerrit-Trigger, but some reason the +1 is failing. 我目前正尝试使用Jenkins Gerrit-Trigger发出“+1 Verified”,但有些原因是+1失败了。

The permissions seem to be in order as the plugin is successfully able to issue "-1 Verified" and "Build Started" comments to the relevant Gerrit changeset. 由于插件能够成功地向相关的Gerrit变更集发出“-1 Verified”和“Build Started”注释,因此权限似乎是有序的。

When the job is successful the "+1 Verified" never materialises. 当工作成功时,“+1已验证”永远不会实现。 Checking the Jenkins logs show that the last entry relevant to the job is showing a 403 response error: 检查Jenkins日志显示与作业相关的最后一个条目显示403响应错误:

The Jenkins logs also show the same request: Jenkins日志也显示相同的请求:

com.sonymobile.tools.gerrit.gerritevents.workers.rest.AbstractRestCommandJob run
SEVERE: Gerrit response: Forbidden

Gerrit also picks up on the request and the 403 response: 格里特也接受了请求和403响应:

"POST /a/changes/tdmdev~develop~Id917dda3449bf9af738ad7f122adaecba70004bd/revisions/7eab7e90c6b7e66f23faaac7cbfd40d8c9c93726/review HTTP/1.1" 403 46 - "Apache-HttpClient/4.5.2 (Java/1.8.0_77)"

I've tested to see if theres any querky goings on with the API and have had success reporting "+1 Verify" using the URL from the Gerrit logs: 我已经过测试,看看是否有任何关于API的问题,并且使用Gerrit日志中的URL成功报告了“+1 Verify”:

curl -v -X POST -d '{"reviewer":"srv_devops_jenkins","labels":{"Verified":"+1"}}' -H "Content-Type: application/json" --user "srv_devops_jenkins:***" --digest http://foobar.com:8080/a/changes/tdmdev~develop~Id917dda3449bf9af738ad7f122adaecba70004bd/revisions/7eab7e90c6b7e66f23faaac7cbfd40d8c9c93726/review

The Gerrit Trigger is configured to support RESTClient requests, I've ensured the following: Gerrit Trigger配置为支持RESTClient请求,我已确保以下内容:

  • RESTClient credentials are correct, clicking the "Test REST Connection" returns a success response. RESTClient凭据是正确的,单击“测试REST连接”将返回成功响应。
  • "Enable Verified" is ticked 勾选“启用已验证”
  • Restarted the Gerrit Trigger connection in Jenkins 重新启动Jenkins中的Gerrit Trigger连接

The only way I've been successful is to disable the "REST API" and have requests made over the SSH connection, the only downside is that we need to issue +1's on custom labels which to the best of my knowledge aren't supported over SSH through the Gerrit-Trigger. 我成功的唯一方法是禁用“REST API”并通过SSH连接发出请求,唯一的缺点是我们需要在自定义标签上发出+ 1,据我所知,这些标签不受支持通过Gerrit-Trigger通过SSH。

Versions:
Jenkins: 2.48
Gerrit-Trigger: 2.23.0
Gerrit: 2.12

Thanks for any help you can provide. 感谢您的任何帮助,您可以提供。

In short this is a Gerrit permission issue for the Jenkins user. 简而言之,这是Jenkins用户的Gerrit权限问题。

The Gerrit trigger when submitting requests over the RESTAPI was including both "Verify" & "Code Review" votes. 通过RESTAPI提交请求时,Gerrit触发器包括“验证”和“代码审查”投票。 Now our Jenkins user only had the Verify permission, so any "Code Review" modification was forbidden (explains the 403 response code). 现在我们的Jenkins用户只拥有了Verify权限,因此禁止任何“Code Review”修改(解释403响应代码)。

Now as a solution it wasn't practical to simply give the Jenkins user "Code Review" permissions. 现在作为一个解决方案,简单地给Jenkins用户“Code Review”权限是不切实际的。 Instead theres an option to configure the Gerrit vote settings within the Jenkins Job: 而是在Jenkins作业中配置Gerrit投票设置的选项:

"Gerrit Trigger" > click "Advanced..." > "Gerrit Reporting Values" “Gerrit Trigger”>点击“高级...”>“Gerrit报告值”

Under the "Verify" heading, adding "1" for successful, while ensuring all other fields are blank allows the RESTAPI to only send the verify +1 vote after the build. 在“验证”标题下,添加“1”表示成功,同时确保所有其他字段为空,允许RESTAPI仅在构建后发送验证+1投票。

在Jenkins >> Gerrit Trigger >>您的服务器名称>> Gerrit报告值>>高级>>重置api,请检查'启用已验证'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM