Azure pipeline does't allow to git push throwing 'GenericContribute' permission is needed

Viewed 35084

I'm trying push some changes done during Azure pipeline using cmd component as follows,

steps:
- script: |
   git config user.email you@you.com
   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:

enter image description here

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?

3 Answers

You need to grant the permissions to Project Collection Build Service (account name):

enter image description here

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.

enter image description here

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:

  1. Copy the guid part of the identity name from the error message
  2. Go to the repository settings
  3. Paste the guid into the permissions search box for user or group.
  4. This will then display a “Project Collection Build Service (OrganisationName)”. Select that user
  5. Set the permissions as stated in other answers.
Related