Container Registry allows you to create a GitLab source code repository and access the repository through GitLab API V3 or V4. This topic describes the procedure for creating a GitLab source code repository in Container Registry.
Before binding Container Registry to your GitLab account, you must obtain a GitLab access token.
In Scopes, select api for the access token. This operation is required because Container Registry needs to obtain the source code repository information and set hooks to trigger automatic build. If the access token has insufficient permissions, you fail to create a GitLab source code repository in Container Registry. In addition, pay attention to the expiration time of the access token to ensure that it is valid in use.
- Go to the Container Registry console and choose Default Instance > Code Source. On the Code Source page, click Bind Account for GitLab. In the Private GitLab dialog box that appears, set parameters and click Bind Account.
URL: Enter the URL of your self-built 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 avatar on GitLab in the upper-right corner, as shown in the following figure. The username is also the credential used to log on to GitLab.
Private Token: Enter the access token obtained in step 1.
Note: Currently, Container Registry does not support access to GitLab behind the firewall or with a self-signed HTTPS certificate. Ensure that GitLab is accessible through the Internet.
Each account can have a maximum of 100 GitLab source code repositories. You can select a namespace and a repository name from the drop-down lists or enter them directly.
- What should 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 possible causes for the error are as follows: (1) GitLab does not respond to your access request. To resolve the problem, ensure that GitLab is accessible through the Internet. Ensure that the firewall is disabled and no self-signed HTTPS certificate is used to access GitLab. In addition, ensure that the account binding information including the GitLab URL, username, and private token is correct. (2) Your GitLab access request times out due to network exceptions. In this case, you can try again later.
- What should 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.”?
The common symptom is that the connection to GitLab is normal but GitLab returns an error code upon a service request. To resolve the problem, ensure that the following conditions are met: (1) The access token has been granted complete read/write access to the GitLab API and has not expired. (2) Your source code account has the permission to set hooks. Ensure that the account has the permission to navigate to Settings > Integrations under the specified repository on GitLab.