Gangmax Blog

GitLab Access Token

When you want to push commits to GitLab repository, you need to have an access token first. To get it, you need to distinguish that there are 2 types of tokens in GitLab.

1. Project access token

The URL is “https://gitlab.com/username/projectname/-/settings/access_tokens“. It seems this token is used in a project only. With this configuation set in service and used in client, the automatic CI pipeline building cannot be triggered properly.

2. Personal access token

The URL is “https://gitlab.com/-/profile/personal_access_tokens“. this token is used accorss GitLab. With this configuation set in service and used in client, the automatic CI pipeline building CAN be triggered properly.

Please make sure you use the second “personal access token” when you want to push commit to GitLab which is able to trigger the CI build. For example, if your “personal access token” value is “abcdefg”, you should execute the following commands:

1
2
3
4
5
6
7
# Remove the existing "origin" remote repository.
git remote remove origin
# Add the URL with access token.
git remote add origin https://oauth2:abcdefg@gitlab.com/user_name/project_name.git
# Done.
git pull
git push origin master

Comments