-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(gitlab): use CI_SERVER_VERSION when available #5783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In some cases (e.g. security reasons), the CI triggerer may not have permission to access the GitLab Version API (401 Unauthorized), and we should prioritize reading from the CI value This problem seems to be common in self-hosted instances (but official instances sometimes have problems) Signed-off-by: Coia Prant (coiaprant@gmail.com)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adjusts the GitLab version retrieval logic to prioritize the CI_SERVER_VERSION environment variable over calling the GitLab Version API, helping avoid 401 Unauthorized errors in restricted environments.
- Prioritizes an environment variable for the GitLab version.
- Falls back to the API call when the environment variable is not set.
- Maintains error logging for debugging purposes.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5783 +/- ##
=======================================
Coverage 82.93% 82.94%
=======================================
Files 161 161
Lines 15932 15935 +3
=======================================
+ Hits 13214 13217 +3
Misses 2144 2144
Partials 574 574 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
That looks good - maybe worth adding a test for it as well?
I don't know how to add a test, it doesn't seem to be the same as the existing one You can push directly to this fork :D |
Yes, IMO it also makes sense to use the predefine variables in the pipeline (https://docs.gitlab.com/ci/variables/predefined_variables/). |
In some cases (e.g. security reasons), the CI triggerer may not have permission to access the GitLab Version API (401 Unauthorized), and we should prioritize reading from the CI value
This problem seems to be common in self-hosted instances (but official instances sometimes have problems)