Azure Pipeline Does't Allow to Git Push Throwing 'Genericcontribute' Permission Is Needed
I'm Trying Push Some Changes Done During Azure Pipeline Using Cmd Component as Follows, Steps: - Script: | Git Config User. Email [Email Protected] Git Config...
I'm trying push some changes done during Azure pipeline using cmd component as follows,
steps:
- script: |
git config user.email [email protected]
git config user.name "your name"
git diff
git add .
git commit -m "version update [skip ci]"
git push origin HEAD:master
But it fails showing following error.
remote: 0000000000aaTF41027: You need the Git 'GenericContribute' permission to perform this action. Details: identity 'Build\sdfdfjjkk', scope 'repository'
I already set the necessary permission as follows:
And the Allow scripts to access the OAuth token is also enabled as mentioned here
What other permissions do I need to give this to work?
4 Answers
If you get the following error in your build...
TF401027: You need the Git ‘GenericContribute’ permission to perform this action. Details: identity
...then, to fix it:
- Copy the guid part of the identity name from the error message
- Go to the repository settings
- Paste the guid into the permissions search box for user or group.
- This will then display a “Project Collection Build Service (OrganisationName)”. Select that user
- Set the permissions as stated in other answers.
You need to grant the permissions to Project Collection Build Service (account name):
It should caused by your account do not have the contribute permission for this repository.
Go Project setting --> Repositories --> click Repos you want to operate -->set repository permissions accordingly.
Even if you have permission but still not able to push the code. Please follow the below steps.
Please check if you have a valid user and password configured in git. If not follow the below steps.
Go to Repository and create a personnel access token which you will use as a password for committing and pushing the code to repos along with your username.
So the best way you can configure your URL while doing the clone.
GitLab Example :
GitLab URL for clone:
GitLab configured URL for clone:
[email protected]/myrepo/demoProject.git. // Follow this approach to clone
Azure Example :
Azure URL for clone:
https://[email protected]/MY-ORG/MyRepo/_git/demo
Azure configured URL for clone:
[email protected]/MY-ORG/MyRepo/_git/demo // Follow this approach to clone
Once you are able to clone these repos then you are all set to commit and push your code.
That’s all. It will save your day!!