Nexus to serve up Chocolately packages
Asked Answered
F

1

7

Not coming from a NuGet background, I don't understand how to setup Nexus to serve up Chocolatey packages.

Fondle answered 24/8, 2017 at 17:30 Comment(2)
Which part didn't you understand? Can you be specific?Simplehearted
I didn't understand what was meant by 'simple server', or how to proxy chocolatey.org. I was trying to use example.com/nexus/content/groups/choco-all for --source, which of course won't work.Fondle
F
16

Here is how you do it:

  1. Create a NuGet proxy repository that points to https://chocolatey.org/api/v2/. This will allow you to cache packages from chocolatey.org which can come in handy if it goes down during a deployment.
  2. Create a NuGet hosted repository. This is where you will publish your private packages.
  3. Create a group repository that contains the above repositories. This what you will set --source flag to when installing a package.

The NuGet tab under hosted repo created above will have the Package Source and Personal API Key.

So if hosted repo has:

Package Source = "https://example.com/nexus/service/local/nuget/choco-releases/"
Personal API Key = "d8471cc1-d350-3e45-a0c2-95d0b938e1d9"

Then the call to package and publish your private mypackage package would look like this:

choco pack
choco push --source "'https://example.com/nexus/service/local/nuget/choco-releases/'" -k="'d8471cc1-d350-3e45-a0c2-95d0b938e1d9'"

To install packages from both private and public sources, use the group repository as the source. The NuGet tab under group repo created above will have the Package Source to use.

So if the group repo has:

Package Source = "https://example.com/nexus/service/local/nuget/choco-all/"

Then the call to install both your private and publicly available packages would look something like this:

choco install jdk8 mypackage --source "'https://example.com/nexus/service/local/nuget/choco-all/'" 

When the jdk8 package is not in the private repo; Nexus will pull it from chocolatey.org, cache it in the proxy repo, then send it on to where choco install is called.

Fondle answered 24/8, 2017 at 21:41 Comment(4)
Just keep in mind that due to distribution rights and a public repository, most packages on the community repository (publicly available) must download those non-redistributable binaries at runtime. Caching the packages locally to a proxy repository is not enough to make them offline. This is why we have a tool called Package Internalizer that makes these packages 100% offline and reliable. chocolatey.org/docs/community-packages-disclaimer is a great read that goes over this. Also see chocolatey.org/docs/features-automatically-recompile-packages.Plimsoll
Have you tested this with Nexus v3? I can't get the choco push command working...Depress
Nevermind, I was trying to upload to the group instead of the hosted repository!Depress
With Nexus 3, the URL has changed to http://hostname/repository/reponame/, and it's essential that there is a trailing /.Heilbronn

© 2022 - 2024 — McMap. All rights reserved.