KubeSphere supports importing code repositories from GitHub, GitLab, Bitbucket, or other Git-based code repositories, such as Gitee.

The following uses a GitHub repository as an example to demonstrate how to import a code repository.

Prerequisites

  • The DevOps extension must be installed and enabled on the KubeSphere platform.

  • A workspace, a DevOps project, and a user (for example, project-regular) have been created. This user must be invited to the DevOps project and granted the operator role. Refer to Invite a User to a DevOps Project.

Steps

  1. Log in to the KubeSphere console as the project-regular user and enter your workspace.

  2. Click  DevOps > Code Repositories in the left navigation pane.

  3. Select a DevOps project from the drop-down list in the upper left corner of the page.

  4. Click Create on the page.

  5. In the Import Code Repository dialog box, enter a name for the code repository and click Select Code Repository.

    The following table lists the supported code repositories and their parameter settings.

    Parameter Description

    GitHub

    Credential: Select the credential for accessing the code repository, such as github-id.

    GitLab

    • GitLab Server Address: Select the GitLab server address. The default value is https://gitlab.com.

    • Project Group/Owner: Enter the GitLab account.

    • Credential: Select the credential for accessing the code repository.

    • Code Repository: Select the code repository.

    Bitbucket

    • Bitbucket Server Address: Set the Bitbucket server address.

    • Credential: Select the credential for accessing the code repository.

    Git

    • Code Repository Address: Enter the code repository address, such as https://gitee.com.

    • Credential: Select the credential for accessing the code repository.

    Note

    To use a private GitLab repository, refer to Create a Multi-branch Pipeline Using GitLab.

  6. The following steps use GitHub as an example. In the Credential area, click Create Credential. In the Create Credential dialog box that appears, set the following parameters and click OK.

    • Name: Enter a name for the credential, such as github-id.

    • Type: Options include Username and Password, SSH Key, Access Token, and kubeconfig. For DevOps projects, Username and Password is recommended.

    • Username: The default username is admin.

    • Password/Token: Enter your GitHub token.

    • Description: Add a description.

    Note

    For more information on how to add credentials, refer to Credentials.

  7. In the Credential drop-down list, select the credential you created and click OK.

  8. In the GitHub repository that appears, select a code repository and click OK to import it. The imported code repository will appear in the list.

  9. Click more on the right side of the code repository to perform the following operations:

    • Edit: Modify the alias and description of the code repository, and reselect the code repository.

    • Edit YAML: Edit the YAML file of the code repository.

    • Delete: Delete the code repository.