Jenkin CI-CD :- Could not update commit status, please check if your scan credentials belong to a member of the organization or a collaborator of the repository and repo:status scope is selected #139667
Unanswered
Swapnil011
asked this question in
Actions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Question
Body
I have done the multi-pipeline project to integrate the jenkin build on a PR merge request.
Toekn is configured with the admin access of the repository and configured the token validation in the jenkin script.
Below is the jenkin file output :
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Commit SHA is: eee919032367bd7d66309208f905d9af823c3db1
[Pipeline] withCredentials
Masking supported pattern matches of $GITHUB_TOKEN
[Pipeline] {
[Pipeline] echo
Updating GitHub status to 'success' for commit SHA 'eee919032367bd7d66309208f905d9af823c3db1'
[Pipeline] sh
curl -X POST -H Accept: application/vnd.github+json -H Authorization: Bearer **** -H X-GitHub-Api-Version: 2022-11-28 https://api.github.com/repos/swapnildtech/tomcat/statuses/eee919032367bd7d66309208f905d9af823c3db1 -d {"state": "success", "context": "continuous-integration/jenkins"}
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 1560 100 1495 100 65 4217 183 --:--:-- --:--:-- --:--:-- 4406
[Pipeline] echo
GitHub response: {
"url": "https://api.github.com/repos/swapnildtech/tomcat/statuses/eee919032367bd7d66309208f905d9af823c3db1",
"avatar_url": "https://avatars.githubusercontent.com/u/109648417?v=4",
"id": 31587414433,
"node_id": "SC_kwDOM2ZH3s8AAAAHWsGxoQ",
"state": "success",
"description": null,
"target_url": null,
"context": "continuous-integration/jenkins",
"created_at": "2024-09-25T06:24:43Z",
"updated_at": "2024-09-25T06:24:43Z",
"creator": {
"login": "Swapnil011",
"id": 109648417,
"node_id": "U_kgDOBokaIQ",
"avatar_url": "https://avatars.githubusercontent.com/u/109648417?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Swapnil011",
"html_url": "https://github.com/Swapnil011",
"followers_url": "https://api.github.com/users/Swapnil011/followers",
"following_url": "https://api.github.com/users/Swapnil011/following{/other_user}",
"gists_url": "https://api.github.com/users/Swapnil011/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Swapnil011/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Swapnil011/subscriptions",
"organizations_url": "https://api.github.com/users/Swapnil011/orgs",
"repos_url": "https://api.github.com/users/Swapnil011/repos",
"events_url": "https://api.github.com/users/Swapnil011/events{/privacy}",
"received_events_url": "https://api.github.com/users/Swapnil011/received_events",
"type": "User",
"site_admin": false
}
}
Also i am getting it updated on PR with below output :
GitHub has been notified of this commit’s build result
Finished: SUCCESS
But it is not updating the commit status:
Could not update commit status, please check if your scan credentials belong to a member of the organization or a collaborator of the repository and repo:status scope is selected
Jenkin Code :
def updateGitHubStatus(String status) {
withCredentials([string(credentialsId: 'jenkin-personal1', variable: 'GITHUB_TOKEN')]) {
echo "Updating GitHub status to '${status}' for commit SHA '${GITHUB_SHA}'"
def response = sh(script: """
curl -X POST -H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $GITHUB_TOKEN"
-H "X-GitHub-Api-Version: 2022-11-28"
"https://api.github.com/repos/${GITHUB_REPO}/statuses/${GITHUB_SHA}"
-d '{"state": "${status}", "context": "continuous-integration/jenkins"}'
""", returnStdout: true).trim()
}
Beta Was this translation helpful? Give feedback.
All reactions