error : You are not allowed to upload code while setting upstream

error : You are not allowed to upload code while setting upstream

我正在尝试使用 git push 命令为 gitlab 中的一个分支设置上游

git push --set-upstream origin hotfix_master_$CI_COMMIT_SHA

这是我正在执行的一组命令

    - echo $CI_COMMIT_SHA   // echo commit SHA 
    - echo "${GITLAB_USER_NAME}" // echo user name 
    - echo "${GITLAB_USER_EMAIL}" // echo user mail 
    - git checkout hotfix_master // get the current working tree/workspace for hotfix_master
    - git pull // pull the latest changes 
    - git checkout -b hotfix_master_$CI_COMMIT_SHA // create new branch from source as hotfix_master 
    - git fetch // get refs from remote and commit in local 
    - git push --set-upstream origin hotfix_master_$CI_COMMIT_SHA  // associate remote branches 

出现以下错误:

remote: You are not allowed to upload code. fatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.com/xxx/xxx-project.git/': The requested URL returned error: 403

已经创建了个人访问令牌并且运行良好。从 commit_sha 开始创建分支时问题就开始了。不知道为什么?我检查过令牌没有过期。 从本地命令提示符,一切正常

$ git push --set-upstream origin hotfix_master_xxxxxxxxxxxxxxxxxxxxxxx
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for hotfix_master_xxxxxxxxxxxxxxxxxxxx, visit:
remote:   https://gitlab.com/xxx/xxx-project/-/merge_requests/new?merge_request%5Bsource_branch%5D=hotfix_master_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
remote:
To https://gitlab.com/xxx/xxx-project.git
 * [new branch]      hotfix_master_xxxxxxxxxxxxxxxxxxxx -> hotfix_master_xxxxxxxxxxxxxxxxxxxxx
Branch 'hotfix_master_xxxxxxxxxxxxxxxxxxx' set up to track remote branch 'hotfix_master_xxxxxxxxxxxxxxxxxxxx' from 'origin'.

无法理解为什么它在 gitlab CI 管道中失败。请推荐

编辑 1

编辑 2

我现在创建了新令牌“gitlab-ci-token”,因为错误表明它正在尝试使用名为“gitlab-ci-token”的令牌,但仍然无法正常工作

https://gitlab-ci-token:[MASKED]@...

URL应该是:

https://oauth2:<the_token>@...

用户名是oauth2。使用 git remote set-url origin.

设置遥控器