Skip to content

Fail to push Nuget package to the package registry in the air-gapped environment

Summary

When trying to push the Nuget package to the registry in the air-gapped environment, an error will occur. https___jihulab.com_gitlab-cn_gitlab_uploads_bae90c229796cdd4552ed09511733d40_image.png

Steps to reproduce

  1. Install GitLab without Internet connection.
  2. Add the Nuget source.
  3. Push the package.
wget -O microsoft.net.test.sdk.16.9.4.nupkg https://www.nuget.org/api/v2/package/Microsoft.NET.Test.Sdk/16.9.4

dotnet nuget add source -n gitlab-nuget "http://10.0.17.66/api/v4/projects/13/packages/nuget/index.json" -u dotnet-rw -p foo --store-password-in-clear-text

dotnet nuget push microsoft.net.test.sdk.16.9.4.nupkg -s "gitlab-nuget"

To trace this failure, we add the following codes to /lib/gitlab/url_blocker.rb:

Gitlab::AppLogger.warn("Address Info Url Is+ uri)

image

After adding the codes, we get the log:

URL is blocked: Host cannot be resolved or invalid

We find that when pushing the package to the registry, GitLab will cache and validate the icon url, license url and the project url where the package belong. Because there is no DNS records for these three urls in the air-gapped environment, the pushing keeps failing.

Edited by ZTZK