Container Registry allows you to create a GitLab source code repository and access the repository by using the GitLab API V3 or V4. This topic describes how to create a GitLab source code repository in the Container Registry console.
By default, port 80 is used. If you want to use other ports, append the port numbers to the end of the webhook URL. You can use only the following port numbers: 80, 21, 443, 70, 210, 280, 488, 591, 777, and from 1025 to 65535.
By default, port 443 is used. Only the default port 443 is supported. If you want to use another port number, use HTTP.
Step 1: Obtain an access token for GitLab
- Obtain an access token for GitLab.
- Select api in the Scopes section. This allows Container Registry to obtain information about the source code repository and set the callback hook for automatically building images from source code through the GitLab API.
Note If the access token you obtained does not have sufficient permissions, you will fail to create a source code repository in the Container Registry console. In addition, pay attention to the validity period of the access token.
Step 2: Bind Container Registry to your GitLab account
- Log on to the Container Registry console. Go to the Code Source page and click Bind Account next to GitLab.
- In the Private GitLab dialog box, set the following parameters:
- URL: Enter the URL of the self-managed GitLab, such as https://my-gitlab.com. Do not enter the URL of a specific repository.
- Username: Enter the username on GitLab.
To obtain the username, click your profile picture on GitLab. This username is the credential that is used to log on to GitLab.
- Private Token: Enter the access token obtained in Step 1.
- Click Confirm.
Step 3: Create a GitLab source code repository
Each account can create a maximum of 100 GitLab source code repositories. We recommend that you select a namespace and a repository name from the drop-down lists or enter them in the fields.
- What can I do if I receive the error message "Failed to access the source code repository site. Please confirm that the account binding information is correct, or try again later"?
The error may occur due to one of the following causes:
- GitLab does not respond to your access request. Make sure that GitLab is accessible over the Internet, no firewall is deployed on the network used to access GitLab, and you do not use a self-signed HTTPS certificate to access GitLab. Verify that the account binding information, including the GitLab URL, username, and access token, is correct.
- Your GitLab access request times out due to network issues. Try again later.
- What can I do if I receive the error message "The source code repository site returns an error response. Please confirm that the account binding information is correct"?
If this error occurs, you can access GitLab normally, but GitLab returns an error.
- Verify that the access token has been granted complete read and write permissions on the GitLab API and has not expired.
- Verify that the specified username has the permission to set the callback hook. To check whether the username has sufficient permissions, log on to GitLab and choose Repository name > Settings > Integrations. On the Integrations page, check whether Push events in the Trigger section is selected.