Search code examples
gitlab-ci

How do I push to GitLab with a project access token?


https://stackoverflow.com/a/52074198/520162 shows a way to push with an access token. But how do I push with a project access token? What is access-token-name in that case?


Solution

  • The answer given by @sytech works but requires you to track token generation count in order to construct a valid username.

    With a little experimenting, I found out that you can also use gitlab-ci-token:

    git remote set-url origin \
      "https://gitlab-ci-token:${YOURTOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"