我正在尝试使用github状态,但documentation不够清楚
假设我的repo项目是https://github.com/politrons/proyectV。
他们在文档中声称这篇文章应该是
POST /repos/:owner/:repo/statuses/:sha有了身体
{
"state": "success",
"target_url": "https://example.com/build/status",
"description": "The build succeeded!",
"context": "continuous-integration/jenkins"
}所以在我的情况下,我正在尝试
发布https://github.com/repos/politrons/proyectV/statuses/1
使用正文
{
"state": "success",
"target_url": "https://example.com/build/status",
"description": "The build succeeded!",
"context": "continuous-integration/jenkins"
}但是github返回404。
你知道我做错了什么吗?一些卷曲的例子,这将是伟大的!
编辑:
我在分支Test-status上创建拉取请求,并在尝试时
curl -v -X GET "https://api.github.com/repos/politrons/proyectV/pulls/1"我收到了json,里面有很多信息。然后,我将获取标头的sha信息并发送此POST命令
curl --request POST --data '{"state": "success", "description": "It works!", "target_url": "http://localhost"}' https://api.github.com/repos/politrons/projectV/statuses/5f4927adcfdc238ba8f46442b737d8ab912cc6ee但之后我收到了
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
} 发布于 2016-10-25 18:39:21
"1“不太可能是存储库中的提交SHA -请注意,状态是在提交上设置的,而不是在拉取请求上设置的,所以如果您想要在拉取请求上设置状态,那么您实际上希望在该拉取请求的头提交上设置它。
使用API获取您的拉流请求(假设为拉流请求1):
GET /repos/politrons/proyectV/pulls/1在curl中:
curl -X GET https://api.github.com/repos/politrons/proyectV/pulls/1允许我们获取头部SHA:
"head": {
"label": "new-topic",
"ref": "new-topic",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
...
}这是您实际设置的状态:
POST /repos/politrons/proyectV/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e在curl中
curl -X POST -H 'Content-Type: application/json' --data '{"state": "success", ...}' https://<token>:x-oauth-basic@api.github.com/repos/politrons/proyectV/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e发布于 2019-08-30 22:14:35
如果您的令牌没有设置状态的权限,则GitHub返回404 Not Found。确保创建了一个具有repo:status作用域的令牌。
发布于 2019-06-19 12:55:55
有同样的问题,在尝试之后反复得到JSON解析错误,做了很少的更改。
导入json data ={ "state":"pending",“context”:“测试自动化BVT",}
"curl -H‘授权: token AUTHCODE’--data '“+ json.dumps(data) + "‘-X POST https://github.com/api/v3/repos/repo_name/statuses/shaValue”
这对我很有效。需要将json.dumps数据作为参数传递。
https://stackoverflow.com/questions/40237009
复制相似问题