As part of a build process in Jenkins, we generate some IDs that need to be written back to a repository. Everything works fine until I try to push the commit with the new IDs back to the origin (bitbucket) on the main or production branches, which have branch restrictions to limit direct commits.
The Jenkins build uses a Repository Access Token to interact with the repo. I have tried to add that token to the "Only specific people or groups have write access" for the branch, but the e-mail, ID, etc. are not accepted as valid values.
Is there a way I can grant that token access to directly write to those branches? If not, is there another workaround I can use?
The specific error I'm getting (URLs removed):
+ git push origin
remote: Permission denied to update branch main.
To <Repo>
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to '<Repo>'
The original looks like this:
git clone https://x-token-auth:<token>@bitbucket.org/<repo>
I also run the line
git config user.email <token-id>@bots.bitbucket.org