Skip to content

Cloning IT Common Platform Code with glab#

Within the IT Common Platform, we utilize the glab CLI tool to clone our entire codebase to local computers. glab is a powerful command-line interface that provides a seamless experience for managing GitLab repositories.

Installation#

To get started with glab, you'll first need to install it on your local machine. Assuming you're using a Mac, you can install glab using Homebrew:

brew install glab
Installation documentation here

Authentication#

Before you can use glab to clone repositories, you'll need to authenticate with the GitLab instance hosted at https://code.vt.edu. You can do this by setting the following environment variables:

export GITLAB_TOKEN=<your_gitlab_token>
export GITLAB_HOST='https://code.vt.edu'

Replace <your_gitlab_token> with your personal GitLab access token. You can generate a new token by following these steps:

  1. Log in to the GitLab web interface.
  2. Click on your profile icon in the top-right corner and select "Settings".
  3. In the left-hand menu, select "Access Tokens".
  4. Fill out the form, providing a name for the token and selecting the appropriate scopes (e.g., api, read_user, write_repository).
  5. Click "Create personal access token" to generate your token.

Cloning the IT Common Platform Codebase#

Once you've set the necessary environment variables, you can use glab to clone the entire IT Common Platform codebase to your local machine. To do this, run the following commands:

glab repo clone --paginate -a=false -p -g 3351
Alternatively, for additional security and automation, the following command extracts the GitLab token from a temporary file and sets the host URL for glab, simplifying the command further:

GITLAB_TOKEN="$(cat /tmp/token)" GITLAB_HOST='https://code.vt.edu' glab repo clone --paginate -a=false -p -g 3351

The first command clones the repository using the GITLAB_TOKEN and GITLAB_HOST environment variables you set earlier. The second command is an alternative method that reads the token from a temporary file /tmp/token.

Additional Resources#

For more information on using glab and GitLab workflows, please refer to the following resources: