With the NuGet repository in Artifactory, we can setup the ability to work with chocolatey packages. Follow the below steps and commands for the setup:
Setup a nuget remote repository pointing to "https://chocolatey.org" and create a virtual Nuget repository "chocolatey-nuget" and include the above remote as well as a local NuGet repository in Artifactory.
Adding source in the client:
choco source add -n artifactory -s="https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget" --priority 1 --bypass-proxy --allow-self-service
To authenticate against Artifactory:
choco apikey -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget" -k admin:cm[...]
choco install packagename --version=x.x -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget" -u admin -p Password
to
choco install packagename --version=x.x -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget" -u admin:cm[...]
For installing the chocolatey :
choco install packagename --version=x.x -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget"
You may also pass the user name and password in the install command using the below command:
choco install packagename --version=x.x -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget" -u admin -p Password
In the request logs, the request for download is seen as below:
2022-06-07T22:42:13.558Z|39353fe562ff4e1c|35.202.14.212|admin|GET|/api/nuget/chocolatey-nuget/Download/packagename/packageversion|200|-1|4438|11|NuGet Core/1.1.0.0 (Microsoft Windows NT 10.0.20348.0)
For pushing the packages to Artifactory:
choco push packagename -s "https://xxx.jfrog.io/artifactory/api/nuget/chocolatey-nuget"
In the request.log the request for upload is seen as below:
2022-06-07T23:32:52.700Z|935e784ac76409a4|35.202.14.212|admin|PUT|/api/nuget/chocolatey-nuget/pacakagename|201|7933|0|273|Chocolatey Command Line/1.1.0.0 (Microsoft Windows NT 10.0.20348.0)