如何将 Artifactory 配置为 Chocolatey 的缓存?安装软件包时出现 404

时间:2021-02-04 09:53:37

标签: artifactory chocolatey

Artifactory 版本:6.16.2 rev 61602900,Artifactory Pro 许可。

在 Artifactory 中,我添加了一个 REMOTE 存储库,具有以下设置:

  • 包类型:NuGet
  • 存储库密钥:chocolatey-remote
  • 网址:https://chocolatey.org/
  • 测试:成功连接到服务器
  • 存储库布局:nuget-default
  • 包括模式:**/*
  • NuGet 下载上下文路径:api/v2/package
  • NuGet 提要上下文路径:api/v2
  • NuGet v3 供稿网址:(空)

截图:

Basic Advanced Replications

在主机上,我已经配置了 Chocolatey 源:

def start_aws_ssm_plugin(self, create_session_response, parameters, profile, region):
    print('start_aws_ssm_plugin() called: ' + str( create_session_response))

    arg0 = '"' + self.config.get_ssm_plugin() + '"'
    arg1 = '"' + str(create_session_response).replace('\'', '\\"') + '"'
    arg2 = region
    arg3 = 'StartSession'
    arg4 = profile
    arg5 = '"' + str(parameters).replace('\'', '\\"') + '"'
    arg6 = 'https://ssm.{region}.amazonaws.com'.format(region=region)

    command = arg0 + ' ' + arg1 + ' ' + arg2 + ' ' + arg3 + ' ' + arg4 + ' ' + arg5 + ' ' + arg6

    print(command)
    # print('session-manager-plugin', arg1, arg2, arg3, arg4, arg5, arg6)

    pid = subprocess.Popen(command).pid
    return pid

# end def

输出:

choco source add --name=artifactory --source=https://<ARTIFACTORY>/api/nuget/chocolatey-remote --user=***REDACTED*** --password=***REDACTED***
choco source disable --name chocolatey
choco source list

运行 PS C:\Users\vagrant> choco source list Chocolatey v0.10.15 artifactory - https://<ARTIFACTORY>/api/nuget/chocolatey-remote (Authenticated)| Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False. chocolatey [Disabled] - https://chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False. 时,我得到了预期的结果:

choco info <PACKAGE>

当我安装软件包时,我得到一个 404:

PS C:\Users\vagrant> choco info vlc   
Chocolatey v0.10.15
vlc 3.0.12
 Title: VLC media player | Published: 1/18/2021
 Number of Downloads: 7848809 | Downloads for this version: 252349
 Package url
 Chocolatey Package Source: n/a
 Package Checksum: 'GNbCKwr6nqOoJc/DX/+riBbXyncp1wV3xOAyYTaOgdls+SiKmvUXoIVXUBGTswQMPIc1tKSdYy+KvuVXb4jliQ==' (SHA512)
 Tags: vlc foss cross-platform multimedia audio video mp3 dvd avi media player admin
 Software Site: http://www.videolan.org/vlc/
 Software License: http://www.videolan.org/legal.html
 Summary: VLC Media Player
 Description: VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols.
(etc)

这是PS C:\Users\vagrant> choco install vlc Chocolatey v0.10.15 Installing the following packages: vlc By installing you accept licenses for the packages. vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found vlc package files install completed. Performing other installation steps. The install of vlc was NOT successful. vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found Chocolatey installed 0/1 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Failures - vlc (exited 1) - vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found

C:\ProgramData\chocolatey\logs\chocolatey.log

如何在没有 404 的情况下获得 Chocolatey 的有效 Artifactory 缓存?

我已经下载了 Artifactory 日志并搜索了 2021-02-04 09:42:36,839 764 [DEBUG] - XmlConfiguration is now operational 2021-02-04 09:42:36,870 764 [INFO ] - ============================================================ 2021-02-04 09:42:36,997 764 [INFO ] - Chocolatey v0.10.15 2021-02-04 09:42:36,997 764 [DEBUG] - Chocolatey is running on Windows v 10.0.17763.0 2021-02-04 09:42:36,997 764 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old". 2021-02-04 09:42:36,997 764 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old". 2021-02-04 09:42:37,010 764 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install vlc 2021-02-04 09:42:37,010 764 [DEBUG] - Received arguments: install vlc 2021-02-04 09:42:37,041 764 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage. 2021-02-04 09:42:37,041 764 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers... 2021-02-04 09:42:37,041 764 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed... 2021-02-04 09:42:37,088 764 [DEBUG] - Performing validation checks. 2021-02-04 09:42:37,088 764 [DEBUG] - Global Configuration Validation Checks: 2021-02-04 09:42:37,088 764 [DEBUG] - - Package Exit Code / Exit On Reboot = Checked 2021-02-04 09:42:37,088 764 [DEBUG] - System State Validation Checks: 2021-02-04 09:42:37,088 764 [DEBUG] - Reboot Requirement Checks: 2021-02-04 09:42:37,088 764 [DEBUG] - - Pending Computer Rename = Checked 2021-02-04 09:42:37,088 764 [DEBUG] - - Pending Component Based Servicing = Checked 2021-02-04 09:42:37,088 764 [DEBUG] - - Pending Windows Auto Update = Checked 2021-02-04 09:42:37,088 764 [DEBUG] - - Pending File Rename Operations = Checked 2021-02-04 09:42:37,088 764 [DEBUG] - - Pending Windows Package Installer = Checked 2021-02-04 09:42:37,108 764 [DEBUG] - - Pending Windows Package Installer SysWow64 = Checked 2021-02-04 09:42:37,108 764 [INFO ] - 2 validations performed. 2 success(es), 0 warning(s), and 0 error(s). 2021-02-04 09:42:37,108 764 [DEBUG] - The source 'https://<ARTIFACTORY>/api/nuget/chocolatey-remote' evaluated to a 'normal' source type 2021-02-04 09:42:37,108 764 [DEBUG] - NOTE: Hiding sensitive configuration data! Please double and triple check to be sure no sensitive data is shown, especially if copying output to a gist for review. 2021-02-04 09:42:37,119 764 [DEBUG] - Configuration: CommandName='install'| CacheLocation='C:\Users\vagrant\AppData\Local\Temp\chocolatey'| ContainsLegacyPackageInstalls='True'| CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'| Sources='https://<ARTIFACTORY>/api/nuget/chocolatey-remote'| SourceType='normal'|Debug='False'|Verbose='False'|Trace='False'| Force='False'|Noop='False'|HelpRequested='False'| UnsuccessfulParsing='False'|RegularOutput='True'|QuietOutput='False'| PromptForConfirmation='True'|AcceptLicense='False'| AllowUnofficialBuild='False'|Input='vlc'|AllVersions='False'| SkipPackageInstallProvider='False'|PackageNames='vlc'| Prerelease='False'|ForceX86='False'|OverrideArguments='False'| NotSilent='False'|ApplyPackageParametersToDependencies='False'| ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'| AllowMultipleVersions='False'|AllowDowngrade='False'| ForceDependencies='False'|Information.PlatformType='Windows'| Information.PlatformVersion='10.0.17763.0'| Information.PlatformName='Windows Server 2016'| Information.ChocolateyVersion='0.10.15.0'| Information.ChocolateyProductVersion='0.10.15'| Information.FullName='choco, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'| Information.Is64BitOperatingSystem='True'| Information.Is64BitProcess='True'|Information.IsInteractive='False'| Information.UserName='vagrant'| Information.UserDomainName='VAGRANT-I7ND05O'| Information.IsUserAdministrator='True'| Information.IsUserSystemAccount='False'| Information.IsUserRemoteDesktop='False'| Information.IsUserRemote='True'| Information.IsProcessElevated='True'| Information.IsLicensedVersion='False'|Information.LicenseType='Foss'| Information.CurrentDirectory='C:\Users\vagrant'| Features.AutoUninstaller='True'|Features.ChecksumFiles='True'| Features.AllowEmptyChecksums='False'| Features.AllowEmptyChecksumsSecure='True'| Features.FailOnAutoUninstaller='False'| Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'| Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'| Features.VirusCheck='False'| Features.FailOnInvalidOrMissingLicense='False'| Features.IgnoreInvalidOptionsSwitches='True'| Features.UsePackageExitCodes='True'| Features.UseEnhancedExitCodes='False'| Features.UseFipsCompliantChecksums='False'| Features.ShowNonElevatedWarnings='True'| Features.ShowDownloadProgress='True'| Features.StopOnFirstPackageFailure='False'| Features.UseRememberedArgumentsForUpgrades='False'| Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'| Features.SkipPackageUpgradesWhenNotInstalled='False'| Features.RemovePackageInformationOnUninstall='False'| Features.ExitOnRebootDetected='False'| Features.LogValidationResultsOnWarnings='True'| Features.UsePackageRepositoryOptimizations='True'| Features.ScriptsCheckLastExitCode='False'| ListCommand.LocalOnly='False'| ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'| ListCommand.PageSize='25'|ListCommand.Exact='False'| ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'| ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'| ListCommand.ApprovedOnly='False'| ListCommand.DownloadCacheAvailable='False'| ListCommand.NotBroken='False'| ListCommand.IncludeVersionOverrides='False'| UpgradeCommand.FailOnUnfound='False'| UpgradeCommand.FailOnNotInstalled='False'| UpgradeCommand.NotifyOnlyAvailableUpgrades='False'| UpgradeCommand.ExcludePrerelease='False'| NewCommand.AutomaticPackage='False'| NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'| SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'| SourceCommand.AllowSelfService='False'| SourceCommand.VisibleToAdminsOnly='False'| FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'| ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'| OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'| 2021-02-04 09:42:37,119 764 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _ 2021-02-04 09:42:37,119 764 [INFO ] - Installing the following packages: 2021-02-04 09:42:37,119 764 [INFO ] - vlc 2021-02-04 09:42:37,119 764 [INFO ] - By installing you accept licenses for the packages. 2021-02-04 09:42:37,166 764 [DEBUG] - Using 'https://<ARTIFACTORY>/api/nuget/chocolatey-remote'. 2021-02-04 09:42:37,338 764 [DEBUG] - - Supports prereleases? 'True'. 2021-02-04 09:42:37,338 764 [DEBUG] - - Is ServiceBased? 'True'. 2021-02-04 09:42:37,544 764 [DEBUG] - Package 'vlc' found on source 'https://<ARTIFACTORY>/api/nuget/chocolatey-remote' 2021-02-04 09:42:37,589 764 [INFO ] - [NuGet] Attempting to resolve dependency 'chocolatey-core.extension (= 1.3.3)'. 2021-02-04 09:42:37,666 764 [ERROR] - vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found 2021-02-04 09:42:37,666 764 [INFO ] - vlc package files install completed. Performing other installation steps. 2021-02-04 09:42:37,666 764 [DEBUG] - No package information as package is null. 2021-02-04 09:42:37,682 764 [DEBUG] - No package information to save as package is null. 2021-02-04 09:42:37,682 764 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers... 2021-02-04 09:42:37,682 764 [ERROR] - The install of vlc was NOT successful. 2021-02-04 09:42:37,682 764 [ERROR] - vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found 2021-02-04 09:42:37,682 764 [WARN ] - Chocolatey installed 0/1 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). 2021-02-04 09:42:37,682 764 [INFO ] - 2021-02-04 09:42:37,697 764 [ERROR] - Failures 2021-02-04 09:42:37,697 764 [ERROR] - - vlc (exited 1) - vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found 2021-02-04 09:42:37,697 764 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers... 2021-02-04 09:42:37,732 764 [DEBUG] - Exiting with 1

choco

$ grep choco *.log access.log:2021-02-04 15:31:38,164 [DENIED DOWNLOAD] chocolatey-remote-cache:vlc.3.0.12.nupkg for client : NA / 91.180.197.91. artifactory.log:2021-02-04 10:57:28,154 [http-nio-8081-exec-992] [INFO ] (o.a.u.r.s.a.c.r.UpdateRepositoryConfigService:64) - Updating repository chocolatey-remote artifactory.log:2021-02-04 14:36:56,347 [http-nio-8081-exec-1053] [INFO ] (o.a.u.r.s.a.c.r.UpdateRepositoryConfigService:64) - Updating repository chocolatey-remote request.log:20210204153137|124|REQUEST|91.180.197.91|anonymous|GET|/api/nuget/chocolatey-remote|HTTP/1.0|200|0 request.log:20210204153137|4|REQUEST|91.180.197.91|anonymous|GET|/api/nuget/chocolatey-remote/$metadata|HTTP/1.0|200|0 request.log:20210204153138|128|REQUEST|91.180.197.91|anonymous|GET|/api/nuget/chocolatey-remote/Packages()|HTTP/1.0|200|0 request.log:20210204153138|16|REQUEST|91.180.197.91|anonymous|GET|/api/nuget/chocolatey-remote/Download/vlc/3.0.12|HTTP/1.0|404|0 看起来与问题相关,但我需要 Artifactory 专家来帮助我理解它的含义。

我在下面的回答中完全像@yahavi 一样运行了 [DENIED DOWNLOAD] chocolatey-remote-cache:vlc.3.0.12.nupkg 命令:

choco

作为健全性检查,我也做了 PS C:\Users\vagrant> choco install vlc --source=https://<ARTIFACTORY>/api/nuget/chocolatey-remote --user=***REDACTED*** --password=***REDACTED*** Chocolatey v0.10.15 Installing the following packages: vlc By installing you accept licenses for the packages. vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found vlc package files install completed. Performing other installation steps. The install of vlc was NOT successful. vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found Chocolatey installed 0/1 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Failures - vlc (exited 1) - vlc not installed. An error occurred during installation: The remote server returned an error: (404) Not Found. Not Found 并且奏效了。这排除了 Chocolatey 方面的任何问题,这绝对是 Artifactory 的问题。

1 个答案:

答案 0 :(得分:-1)

尝试将 NuGet v3 Feed URL 设置为默认值:https://api.nuget.org/v3/index.json

我们在 tests 中使用 Artifactory 作为 Chocolatey 的缓存机制。 用法与您的不太一样,因为我们在安装命令中添加了连接详细信息:

choco install vlc -s <jfrog-url>/api/nuget/chocolatey-remote -u <username> -p <password>

如需了解更多信息,欢迎阅读我的博客: https://jfrog.com/blog/artifactory-as-a-caching-mechanism-for-package-managers/