I am new to GitLab CI/CD jobs, but I\'m trying to set up a Python script that when pushed to GitLab, triggers the CI/CD job to run it, and call an internal function that pus
The command we ended up using was:
git tag my-new-tag
git push --repo=git@YOUR_REPO_URL:YOUR_GROUP/YOUR_PROJECT.git --tags
By default we were getting:
remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@YOUR_REPO_URL:YOUR_FORK/YOUR_PROJECT.git/': The requested URL returned error: 403`
The reason is because the CI runner executes git commands using the HTTPS protocol with a token that does not support push as stated by @VonC.
We have configured our runner to share a volume to the /root/.ssh
directory. So using the git
protocol and a proper ssh
configuration we are able to push git commands using the Gitlab CI runner.
The gitlab
runner is exectuded as follows (I removed useless parameters for the purpose of clarity)
docker exec -it gitlab-runner.service gitlab-runner register \
--non-interactive \
--name `hostname` \
--url "some-gitlab-url" \
...
--executor "docker" \
--limit "1" \
--docker-image "debian" \
--docker-volumes "/var/run/docker.sock:/var/run/docker.sock" \
--docker-volumes "/fs1/runner/builds:/builds" \
--docker-volumes "/fs1/runner/cache:/cache" \
--docker-volumes "/fs1/runner/profile:/root" \
So the /root
directory is shared across all our runners. Therefore once configured properly with /root/.ssh/
proper keys and those keys have the right to push
to gitlab, it will work as described above.