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?
Asked
Active
Viewed 7,377 times
2 Answers
5
Project access tokens work exactly the same as personal access tokens. The access token belongs to the project bot user that is created when you create the token.
So, in this case, you should be using the username, which is project_{project_id}_bot
for the first access token created. For subsequent tokens, the username is project_{project_id}_bot{bot_count}
So you would do something like this:
git remote add origin \
"https://project_1234_bot:YOURTOKEN@gitlab.example.com/path/to/project.git"

sytech
- 29,298
- 3
- 45
- 86
2
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"

eckes
- 64,417
- 29
- 168
- 201