How to configure Artifactory as a cache for Chocolatey? I get 404 when installing packages

浪尽此生 提交于 2021-02-10 17:54:34

问题


Artifactory version: 6.16.2 rev 61602900, Artifactory Pro license.

In Artifactory, I have added a REMOTE repository, with the following settings:

  • Package Type: NuGet
  • Repository Key: chocolatey-remote
  • URL: https://chocolatey.org/
  • Test: Successfully connected to server
  • Repository Layout: nuget-default
  • Include Patterns: **/*
  • NuGet Download Context Path: api/v2/package
  • NuGet Feed Context Path: api/v2
  • NuGet v3 Feed URL: (empty)

Screenshots:

On the host, I have configured Chocolatey sources:

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

Output:

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.

When running choco info <PACKAGE>, I get an expected result:

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)

When I install packages, I get a 404:

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

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

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

How do I get a working Artifactory cache of Chocolatey without a 404?

I have downloaded the Artifactory logs and grepped for 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

The line [DENIED DOWNLOAD] chocolatey-remote-cache:vlc.3.0.12.nupkg looks relevant to the issue, but I'd need an Artifactory expert to help me understand what it means.

I ran the choco command exactly like @yahavi in answer below:

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

As a sanity check, I also did choco install vlc --source=https://chocolatey.org/api/v2/ and that worked. This rules out any issue on Chocolatey's side, it's most definitely an issue with Artifactory.


回答1:


Try to set the NuGet v3 Feed URL to be the default value: https://api.nuget.org/v3/index.json.

We use Artifactory as a caching mechanism for Chocolatey in our tests. The usage is not exactly like yours, since we add the connection details in the install command:

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

To get more information, you're welcome to read my blog: https://jfrog.com/blog/artifactory-as-a-caching-mechanism-for-package-managers/



来源:https://stackoverflow.com/questions/66043223/how-to-configure-artifactory-as-a-cache-for-chocolatey-i-get-404-when-installin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!