Skip to content

Conversation

rbqvq
Copy link
Contributor

@rbqvq rbqvq commented May 23, 2025

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)

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 23, 2025
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)
@rbqvq rbqvq force-pushed the ci-server-version branch from b32c149 to 7a0aeef Compare May 23, 2025 07:31
@caarlos0 caarlos0 requested a review from Copilot May 23, 2025 17:24
@caarlos0 caarlos0 added the enhancement New feature or request label May 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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.

Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.94%. Comparing base (78104b3) to head (7a0aeef).
Report is 21 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@caarlos0 caarlos0 left a 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?

@rbqvq
Copy link
Contributor Author

rbqvq commented May 29, 2025

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

@mavogel
Copy link
Member

mavogel commented May 30, 2025

Yes, IMO it also makes sense to use the predefine variables in the pipeline (https://docs.gitlab.com/ci/variables/predefined_variables/).

@caarlos0 caarlos0 merged commit df9647c into goreleaser:main Jun 5, 2025
17 checks passed
caarlos0 added a commit that referenced this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants