Cannot push from a project to another

Hi !

I am using GitLab with my company. We are developing very interesting things in our C++ library (that’s just my opinion :p) and GitLab helped a lot to implement a continuous integration process. We already use it in order to:

  • Build & Test our library in Debug mode
  • Build & Test our library in Release mode
  • Check if there are any memory leaks
  • Check if some symbols are here while they shouldn’t
  • Generate documentation

Lately we have been thinking about adding a profiling stage to those process so we can see how our optimization works are influencing the performance of the library. We want it a bit like our documentation generation, a GitLab runner is responsible to push the modifications (i.e. the documentation or the benchmarks) in the relevant project.

We already made this using the SSH key method but for our benchmarks we would like to avoid that and use existing GitLab variables for that.

Here are the stage details:

    - linux
    - shell
    - light
  stage: profiling
  allow_failure: false
    - new-benchmark-stage
    - git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git &> /dev/null
    - cd benchmarks
    - touch test.dat
    - echo "This is a test" > test.dat
    - git config --global "${GITLAB_USER_NAME}"
    - git config --global "${GITLAB_USER_EMAIL}"
    - git add --all
    - git commit -m "Uploader"
    - git push http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mycompany.home/developers/benchmarks.git HEAD:master
    - cd ..

It works well until the push step. Even if I try different techniques to push new files (i.e. git push origin master) I always have the same error:

remote: You are not allowed to upload code for this project.
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.mycompany.home/developers/benchmarks.git/': The requested URL returned error: 403

I am the owner of the project and the master branch is unprotected.

What am I doing wrong here ?

I ran into the same problem.

Looks like there’s a feature request here:

And a workaround here:

Hi guys…
I resolved this problem with a “personal access token” in Settings of my profile. I created a token with scope api and configure in my pipeline. Open the project in gitlab console, go to Settings > CI/CD > Secret variables, create a variable with value the key (generated in profile). I replace “{CI_JOB_TOKEN}" to my variable "{VAR01}”.
Best regards.

Hi @danilohalves

How exactly did you replace the CI_JOB_TOKEN? I tried assigning it under variables in gilab-ci.yml with lo

Ended up fixing it using this the gitlab-ci.yml

   - url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
   - git remote set-url origin "https://gitlab-ci-token:${CI_TAG_UPLOAD_TOKEN}@${url_host}"

CI_TAG_UPLOAD_TOKEN is the Secret variable

1 Like