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

Time:12-24

I'm trying to set the upstream for one of the branch in gitlab using git push command

git push --set-upstream origin hotfix_master_$CI_COMMIT_SHA

here are the set of commands which I'm executing

    - 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 

Getting following error :

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

have already created the personal access token and was working fine . issue started when started creating branch from the commit_sha . not sure why ? I have checked the token is not expired . from local command prompt , everything works

$ 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'.

not able to understand why it is failing from gitlab CI pipeline. please suggest

EDIT 1

enter image description here

EDIT 2

I have created now new token "gitlab-ci-token" as the error indicates that, it is trying to use the token named "gitlab-ci-token" still not working

enter image description here

CodePudding user response:

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

The URL should be:

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

The username is oauth2. Set the remote with git remote set-url origin.

  • Related