GITLAB_TOKEN and GL_HOST env vars are ignored by the glab cli
Checklist
- I'm using the latest version of the extension (Run
glab --version) - Operating system and version: MacOS 14.4.1
- Gitlab.com or self-managed instance? self-managed
- GitLab version (if self-managed) 15.11.13-ee
- I have performed
glab auth statusto check for authentication issues
Summary
The glab cli can't seem to read the GITLAB_TOKEN (or GITLAB_HOST) anymore, even though documentation states otherwise. The only way I can authenticate now is through glab auth login and the config.yml file.
Environment
- OS: MacOS
- SHELL: MacOS Terminal - zsh
glab version 1.40.0 (2024-04-24) Attempting to sign into a self hosted gitlab instance (I don't think this is the issue, but it's a detail nevertheless)
Other:
Steps to reproduce
export GITLAB_TOKEN=**************************
export GITLAB_HOST=gitlab.self_hosted.io
glab auth status
What is the current bug behavior?
Output:
x gitlab.com: api call failed: GET https://gitlab.com/api/v4/user: 401 {message: 401 Unauthorized}
✓ Git operations for gitlab.com configured to use ssh protocol.
✓ API calls for gitlab.com are made over https protocol
✓ REST API Endpoint: https://gitlab.com/api/v4/
✓ GraphQL Endpoint: https://gitlab.com/api/graphql/
x No token providedWhat is the expected correct behavior?
Output:
gitlab.com
x gitlab.com: api call failed: GET https://gitlab.com/api/v4/user: 401 {message: 401 Unauthorized}
✓ Git operations for gitlab.com configured to use ssh protocol.
✓ API calls for gitlab.com are made over https protocol
✓ REST API Endpoint: https://gitlab.com/api/v4/
✓ GraphQL Endpoint: https://gitlab.com/api/graphql/
x No token provided
gitlab.self_hosted.io
✓ Logged in to gitlab.self_hosted.io as andi.titu (/Users/andititu/.config/glab-cli/config.yml)
✓ Git operations for gitlab.self_hosted.io configured to use ssh protocol.
✓ API calls for gitlab.self_hosted.io are made over https protocol
✓ REST API Endpoint: https://gitlab.self_hosted.io/api/v4/
✓ GraphQL Endpoint: https://gitlab.self_hosted.io/api/graphql/
✓ Token: **************************Relevant logs and/or screenshots
(The showcased token is now revoked)

Possible fixes
Did not look into the code
Edited by Andi Titu