Skip to content

Integrate GitHub/GitLab in Tektonβš“οΈŽ

This page describes how to integrate EDP with GitLab or GitHub Version Control System.

Integration Procedureβš“οΈŽ

To start from, it is required to add both Secret with SSH key, API token, and GitServer resources by taking the steps below.

  1. Generate an SSH key pair and add a public key to GitLab or GitHub account.

    ssh-keygen -t ed25519 -C "email@example.com"
    
  2. Generate access token for GitLab or GitHub account with read/write access to the API. Both personal and project access tokens are applicable.

    To create access token in GitHub, follow the steps below:

    • Log in to GitHub.
    • Click the profile account and navigate to Settings -> Developer Settings.
    • Select Personal access tokens (classic) and generate a new token with the following parameters:

    Repo permission
    Repo permission

    Note

    The access below is required for the GitHub Pull Request Builder plugin to get Pull Request commits, their status, and author info.

    Admin:repo permission
    Admin:repo permission
    Admin:org permission
    Admin:org permission
    User permission
    User permission

    Warning

    Make sure to save a new personal access token because it won`t be displayed later.

    To create access token in GitLab, follow the steps below:

    • Log in to GitLab.
    • In the top-right corner, click the avatar and select Settings.
    • On the User Settings menu, select Access Tokens.
    • Choose a name and an optional expiry date for the token.
    • In the Scopes block, select the api scope for the token.

    Personal access tokens
    Personal access tokens

    • Click the Create personal access token button.

    Note

    Make sure to save the access token as there will not be any ability to access it once again.

    In case you want to create a project access token instead of a personal one, take the following steps:

    • Log in to GitLab and navigate to the project.
    • On the User Settings menu, select Access Tokens.
    • Choose a name and an optional expiry date for the token.
    • Choose a role: Owner or Maintainer.
    • In the Scopes block, select the api scope for the token.

    Project access tokens
    Project access tokens

    • Click the Create project access token button.
  3. Create a secret in the edp namespace for the Git account with the id_rsa, username, and token fields. Take the following template as an example (use ci-gitlab instead of ci-github for GitLab):

    Navigate to EDP Portal -> EDP -> Configuration -> Git Servers. Fill in the required fields:

    VCS Integration in EDP portal
    Project access tokens

    Create a manifest file called secret.yaml with the following content filled in:

    kubectl apply -f - <<EOF
          apiVersion: v1
          kind: Secret
          metadata:
            name: ci-github
            namespace: edp
            labels:
              app.edp.epam.com/secret-type: repository
          type: Opaque
          stringData:
            id_rsa: <id_rsa_data>
            username: git
            token: <your_github_access_token>
    EOF
    

As a result, you will be able to create codebases using an integrated Version Control System.