How to switch between hosts on glab CLI

When using glab (GitLab.org / cli · GitLab), is there a way to pass a “–host” parameter to specify which host to use based on entries in the config.yml file? My config.yml file looks [partially] like this:

# configuration specific for gitlab instances
hosts:
    hostA:
        # What protocol to use to access the api endpoint. Supported values: http, https
        api_protocol: https
        # Configure host for api endpoint, defaults to the host itself
        api_host: host_a_url.com
        # Your GitLab access token. Get an access token at https://gitlab.com/-/profile/personal_access_tokens
        token: <token_value>
    gitlab:
        api_protocol: https
        api_host: gitlab_example.com
        token: <token_value>
# Default GitLab hostname to use
host: hostA

When on the command line, I would expect the command to look something like

glab repo clone --host gitlab -g <group_id> -p --paginate

but I can’t seem to find if a parameter exists like “–host” to allow me to switch between the hosts identified in the config.yml file for running individual commands.

You can use the GITLAB_HOST variable to specify which host to clone from.

GITLAB_HOST=salsa.debian.org glab repo clone  -g <group> --paginate
1 Like