我正在嘗試使用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
得到以下錯誤:
遠程:您不允許上傳代碼。致命:無法訪問“https://gitlab-ci-token:[MASKED]@gitlab.com/xxx/xxx-project.git/”:請求的 URL 回傳錯誤: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[source_branch]=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”的令牌仍然無法正常作業

uj5u.com熱心網友回復:
https://gitlab-ci-token:[MASKED]@...
網址應該是:
https://oauth2:<the_token>@...
用戶名是oauth2。用 設定遙控器git remote set-url origin。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/391830.html
上一篇:獲取遠程和本地分支的差異
下一篇:使用本地更改更新Git子模塊
