Repo – Allow Build Agent to Commit Code
Being able to commit code and other aspects into git source code is something you may find odd. After all the source code is is your companies intellectual property, so why would you want to let you build agent make changes to your code? If you keep your documentation next to your source code for example a wiki, you may want to automatically generate your release notes and check them in.
Lets get started
You need to head over to Project Settings > Repositories > Git repositories. You will see a list of Groups under Azure DevOps Groups and then Users, the one we are interested in is the Build Service. It will look something like below.
To enable the build agent to check in we need to enable some of the options which are set to Not Set. Update the options with the ones below with green ticks next to them
When you want to make a change or add code to the repository you need to enable a option on the pipeline. You need to let the pipleline components to authenticate in YAML use the step below or if you are using classic use Allow scripts to access OAuth token on the agents settings within the pipeline, it is under Additional Options.
If you get “TF401027: You need the Git ‘GenericContribute’ permission to perform this action. Details: identity” error in your build. First copy and past the guid part of the identity name and paste it on the search for user or group. This will then display a “Project Collection Build Service (OrganisationName)”. Set the permissions as above.