I created a project access token and am trying to use it in a separate project to update dependencies in that project. Here’s the CI/CD in the Dependency Updater project:
stages:
- run
run:
image: elixir:1.14.3-alpine
stage: run
parallel:
matrix:
- REPOSITORY: willow
ACCESS_TOKEN: $WILLOW_ACCESS_TOKEN
PROJECT_ID: 44672376
only:
- schedules
script:
- apk update && apk add git && apk add curl
- git clone https://gitlab-ci-token:$ACCESS_TOKEN@gitlab.com/willow3542912/$REPOSITORY.git
- cd $REPOSITORY
- mix local.hex --force
- mix local.rebar --force
- git checkout -b deps-update-$CI_PIPELINE_ID
# UPDATE THE DEPENDENCIES
- mix deps.clean --unlock --unused
- mix deps.update --all
- git add .
- git config --global user.email "bot@example.com"
- git config --global user.name "project_44672376_bot_05c90160d9596b1001e2351b09b7a483"
- git commit -m "Dependency Updater Bot"
# PUSH THE CHANGES
- git push --set-upstream origin deps-update-$CI_PIPELINE_ID
# CREATE A MERGE REQUEST
- 'curl --request POST --url https://gitlab.com/api/v4/projects/$PROJECT_ID/merge_requests --header "Content-Type: application/json" --header "PRIVATE-TOKEN: $ACCESS_TOKEN" --data "{\"source_branch\": \"deps-update-$CI_PIPELINE_ID\", \"target_branch\": \"main\", \"title\": \"Dependency Updates (Automated)\", \"remove_source_branch\": true, \"assignee_ids\": [14056526, 14057153, 5497843, 14056322]}"'
The problem is that I’m getting this error:
remote: GitLab: You cannot push commits for 'bot@example.com'. You can only push commits if the committer email is one of your own verified emails.
I tried changing the username to the actual username of the user that the project access token generated, and the email to that name + @gitlab.com but that also didn’t work:
remote: GitLab: You cannot push commits for 'project_44672376_bot_05c90160d9596b1001e2351b09b7a483@gitlab.com'. You can only push commits if the committer email is one of your own verified emails.