I created a personal access token in the project so that when I created a tag it would update the version of a file and commit again and sends it to main branch.
Project is inside gitlab.com hosted
Suppose the project id is 12345 and the email created after creating the project access token is project_12345_bot@noreply.gitlab.com.
The tag update script would look like this:
update-version:
stage: update
variables:
BRANCH_TAG: main
script:
- apk add git curl jq
- mkdir /update-project && cd /update-project
- git clone ${PROJECT_REPO}
- git config --global user.email "${PROJECT_EMAIL_BOT}"
- git config --global user.name "'${PROJECT_NAME_BOT}'"
- pwd
- cd project-x/
- jq --arg tag "${CI_COMMIT_TAG}" '.version=$tag' composer.json > new_composer.json
- mv new_composer.json composer.json
- cat composer.json
- git add composer.json
- git commit -m "Update version ${CI_COMMIT_TAG} in composer.json"
- git log -1
- git tag --force ${CI_COMMIT_TAG}
- git push origin ${BRANCH_TAG} --force
- git push -o ci.skip origin ${CI_COMMIT_TAG} --force
only:
- tags
The error you are giving is this through the log:
$ git push origin ${BRANCH_TAG} --force
remote: GitLab: Author 'project_12345_bot@noreply.gitlab.com' is not a member of team
To https://gitlab.com/.../project-x.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://project_12345_bot:[ACCESS_TOKEN]@gitlab.com/.../project-x.git'
It used to work, but now it’s not working anymore, it says that the gitlab email is not a team member, but it is the PROJECT_ACCESS_TOKEN email.
Would you help me?