I set up my Pipeilne to run:
- git config user.email “firstname.lastname@example.org”
- git config user.name “Build User”
- git add VERSION
- git commit -m “deploy version update [skip ci]”
- git push -u origin master
Everything runs fine up until the push where I get:
remote: You are not allowed to upload code.
fatal: unable to access ‘https://gitlab-ci-token:email@example.com/user/project.git/’: The requested URL returned error: 403
I have the master branch protected; however, I would like to add the build user so that the VERSION file can be changed before my deployment. How can I add permissions for the build user to be able to push to the master branch?
In your repository in the “settings/repository” section, you can expand the option “Protected Branches” and there you can add the specific user who whants to give you the permissions.
Example of url to get to the section of protected branches:
Documentation that can be supported for more detail:
There’s no option for the default GitLab build user.
Would I need to add a whole new user and add an SSH key in there?
@revof11 Hi Revo, I am facing the same issue here. Any updates for the solution? thanks
Nothing yet - but I haven’t exactly tried in a while. I found some workarounds instead.
I had to get deep into some Bash Fu to do what I needed.
Has anyone else managed to get this to work? I currently have:
protected master branch (with no one allowed to push)
using mvn release plugin
scm configured in the POM as:
- 'which ssh-agent || ( apk update && apk add openssh-client git )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git remote set-url origin $CI_REPOSITORY_URL
- git config --global user.email "<email to match private key>"
- git config --global user.name "<name>"
- mvn release:prepare release:perform
This push fails with:
`[ERROR] fatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.com/<path>/<project>.git/': The requested URL returned error: 403`