Skip to content

Commit 80b471c

Browse files
committed
(#230) Adds ChocolateyCore Repository and Jenkins Job
- Add ChocolateyCore repo as main repo for core packages - Add callout to new ChocolateyCore repository - Remove See It In Action README section as video is outdated - Fixup spelling/grammar in README - Add new Update ChocolateyCore Repository Jenkins Job - Add test to check for new Jenkins job - Remove legacy build files from new and existing Jenkins jobs
1 parent 0a114fa commit 80b471c

File tree

16 files changed

+120
-46
lines changed

16 files changed

+120
-46
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains a set of supporting scripts used for the Chocolatey for Business (C4B) Quick-Start Guide (QSG).
44

5-
These scripts can be used to assist in setup of a brand new Windows Server as a C4B Server.
5+
These scripts can be used to assist in the setup of a brand-new Windows Server as a C4B Server.
66

77
Below is the Quick Start Guide as it exists currently on the [Chocolatey Docs](https://docs.chocolatey.org/en-us/guides/organizations/quick-start-guide/chocolatey-for-business-quick-start-guide).
88

@@ -34,14 +34,16 @@ As illustrated in the diagram above, there are four main components to a Chocola
3434

3535
1. **C4B Licensed components**: A licensed version of Chocolatey includes:
3636
- Installation of the Chocolatey OSS client package itself (`chocolatey`)
37-
- Chocolatey license file (`chocolatey.license.xml`) installed in the correct directory (`ProgramData\chocolatey\license`)
37+
- The Chocolatey license file (`chocolatey.license.xml`) installed in the correct directory (`ProgramData\chocolatey\license`)
3838
- Installation of the Chocolatey Licensed extension (`chocolatey.extension`), giving you access to features like Package Builder, Package Internalizer, etc. (full list [here](https://docs.chocolatey.org/en-us/features/)).
3939

40-
1. **NuGet V3 Repository Server App (Nexus)**: Chocolatey works best with a NuGet V3 repository. This application hosts and manages versioning of your Chocolatey package artifacts, in their enhanced NuGet package (.nupkg) file format. The quick start guide helps you setup [Sonatype Nexus Repository Manager (OSS)](https://www.sonatype.com/products/nexus-repository).
40+
1. **Repository Server (Sonatype Nexus)**: Chocolatey works best with a NuGet repository. This repository hosts and manages the versioning of your Chocolatey package artifacts, in their enhanced NuGet package (.nupkg) file format. The quick start guide helps you set up [Sonatype Nexus Repository Manager (OSS)](https://www.sonatype.com/products/nexus-repository).
4141

42-
1. **Chocolatey Central Management (CCM)**: CCM is the Web UI portal for your entire Chocolatey environment. Your endpoints check-in to CCM to report their package status. This includes the Chocolatey packages they have installed, and whether any of these packages are outdated. And now, with CCM Deployments, you can also deploy packages or package updates to groups of endpoints, as well as ad-hoc PowerShell commands. CCM is backed by an MS SQL Database. This guide will set up MS SQL Express for you.
42+
1. **Chocolatey Central Management (CCM)**: CCM is a web-based application for managing the state of Chocolatey packages in your environment. Your endpoints check in via the Chocolatey agent and report basic computer information (host name, IP address), and what Chocolatey packages are installed, as well as if any of those packages are outdated. A deployment capability allows you to install, upgrade, or uninstall packages, and for more advanced scenarios run ad-hoc PowerShell code on your endpoints.
4343

44-
1. **Automation Pipeline (Jenkins)**: A pipeline tool will help you automate repetitive tasks, such checking for updates to a set of Chocolatey Packages from the Chocolatey Community Repository (CCR). If updates exist, the pipeline task will auto-internalize your list of packages, and push them into your NuGet repository for you. This guide will help you set up Jenkins as your automation pipeline.
44+
CCM is backed by an MS SQL Database, which this guide will set up and configure for you based on Microsoft SQL Server Express.
45+
46+
1. **Automation Pipeline (Jenkins)**: A pipeline tool will help you automate repetitive tasks, such as checking for updates to a set of Chocolatey Packages from the Chocolatey Community Repository (CCR). If updates exist, the pipeline task will auto-internalize your list of packages, and push them into your NuGet repository for you. This guide will help you set up Jenkins as your automation pipeline.
4547

4648
## Requirements
4749

@@ -62,7 +64,7 @@ Below are the minimum requirements for setting up your C4B server via this guide
6264

6365
1. Install all Windows Updates.
6466

65-
1. If you plan on joining this server to your Active Directory domain, do so now before beginning setup below.
67+
1. If you plan on joining this server to your Active Directory domain, do so now before beginning the setup below.
6668

6769
1. If you plan to use a Purchased/Acquired or Domain SSL certificate, please ensure the CN/Subject value matches the DNS-resolvable Fully Qualified Domain Name (FQDN) of your C4B Server. Place this certificate in the `Local Machine > Personal` certificate store, and ensure that the private key is exportable.
6870

@@ -120,9 +122,11 @@ Below are the minimum requirements for setting up your C4B server via this guide
120122
> <ul class="list-style-type-disc">
121123
> <li>Installs Sonatype Nexus Repository Manager OSS instance</li>
122124
> <li>Cleans up all demo repositories on Nexus</li>
125+
> <li>Creates a "ChocolateyCore" NuGet repository</li>
123126
> <li>Creates a "ChocolateyInternal" NuGet repository</li>
124127
> <li>Creates a "ChocolateyTest" NuGet repository</li>
125128
> <li>Creates a "choco-install" raw repository</li>
129+
> <li>Sets up "ChocolateyCore" on C4B Server as source, with API key</li>
126130
> <li>Sets up "ChocolateyInternal" on C4B Server as source, with API key</li>
127131
> <li>Adds firewall rule for repository access</li>
128132
> <li>Installs MS Edge, and disables first-run experience</li>
@@ -177,7 +181,7 @@ Below are the minimum requirements for setting up your C4B server via this guide
177181
.\Set-SslSecurity.ps1
178182
```
179183
180-
**ALTERNATIVE 1 : Custom SSL Certificate** - If you have your own custom SSL certificate (purchased/acquired, or from your Domain CA), you can paste and run the following script with the `Thumbprint` value of your SSL certificate specified:
184+
**ALTERNATIVE 1: Custom SSL Certificate** - If you have your own custom SSL certificate (purchased/acquired, or from your Domain CA), you can paste and run the following script with the `Thumbprint` value of your SSL certificate specified:
181185
182186
```powershell
183187
Set-Location "$env:SystemDrive\choco-setup\files"
@@ -189,7 +193,7 @@ Below are the minimum requirements for setting up your C4B server via this guide
189193
> :memo: **NOTE**
190194
> You may have noticed the `-Hardened` parameter we've added above. When using a custom SSL certificate, this parameter will further secure access to your C4B Server. A Role and User credential will be configured to limit access to your Nexus repositories. As well, CCM Client and Service Salts are configured to further encrypt your connection between CCM and your endpoint clients. These additional settings are also incorporated into your `Register-C4bEndpoint.ps1` script for onboarding endpoints. We do require you to enable this option if your C4B Server will be Internet-facing, with a FQDN that resolves to a public IP.
191195
192-
**ALTERNATIVE 2 : Wildcard SSL Certificate** - If you have a wildcard certificate, you will also need to provide a DNS name you wish to use for that certificate:
196+
**ALTERNATIVE 2: Wildcard SSL Certificate** - If you have a wildcard certificate, you will also need to provide a DNS name you wish to use for that certificate:
193197
194198
```powershell
195199
Set-Location "$env:SystemDrive\choco-setup\files"
@@ -272,9 +276,3 @@ Below are the minimum requirements for setting up your C4B server via this guide
272276
Congratulations! If you followed all the steps detailed above, you should now have a fully functioning Chocolatey for Business implementation deployed in your environment.
273277
274278
It is worth mentioning that some customers may have a more bespoke environment, with the presence of proxies and additional configuration management applications. Chocolatey is engineered to be quite flexible, specifically to account for these scenarios. Please refer to the many options for installation referenced on the [Installation page](https://docs.chocolatey.org/en-us/licensed-extension/setup#more-install-options). Again, If you have any questions or would like to discuss more involved implementations, please feel free to reach out to your Chocolatey representative.
275-
276-
### See it in Action
277-
278-
If you'd prefer to watch and follow along, here is a recording of our Chocolatey Team going through this guide live on our Twitch stream:
279-
280-
[YouTube Video](https://www.youtube.com/embed/qbIclPMEgig)

Set-SslSecurity.ps1

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ process {
139139
Write-Host "Nexus is ready!"
140140

141141
choco source remove --name="'ChocolateyInternal'"
142-
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
142+
$InternalRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
143+
144+
choco source remove --name="'ChocolateyCore'"
145+
$CoreRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyCore/index.json"
143146

144147
# Build Credential Object, Connect to Nexus
145148
$securePw = (Get-Content 'C:\programdata\sonatype-work\nexus3\admin.password') | ConvertTo-SecureString -AsPlainText -Force
@@ -187,12 +190,23 @@ process {
187190
'source',
188191
'add',
189192
"--name='ChocolateyInternal'",
190-
"--source='$RepositoryUrl'",
193+
"--source='$InternalRepositoryUrl'",
191194
'--priority=1',
192195
"--user='chocouser'",
193196
"--password='$NexusPw'"
194197
)
195198
& choco @ChocoArgs
199+
200+
$ChocoArgs = @(
201+
'source',
202+
'add',
203+
"--name='ChocolateyCore'",
204+
"--source='$CoreRepositoryUrl'",
205+
'--priority=0',
206+
"--user='chocouser'",
207+
"--password='$NexusPw'"
208+
)
209+
& choco @ChocoArgs
196210

197211
}
198212

@@ -201,22 +215,34 @@ process {
201215
'source',
202216
'add',
203217
"--name='ChocolateyInternal'",
204-
"--source='$RepositoryUrl'",
218+
"--source='$InternalRepositoryUrl'",
205219
'--priority=1'
206220
)
207221
& choco @ChocoArgs
222+
223+
$ChocoArgs = @(
224+
'source',
225+
'add',
226+
"--name='ChocolateyCore'",
227+
"--source='$CoreRepositoryUrl'",
228+
'--priority=0'
229+
)
230+
& choco @ChocoArgs
208231
}
209232

210233
# Update Repository API key
211-
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
234+
$chocoArgs = @('apikey', "--source='$InternalRepositoryUrl'", "--api-key='$NuGetApiKey'")
235+
& choco @chocoArgs
236+
237+
$chocoArgs = @('apikey', "--source='$CoreRepositoryUrl'", "--api-key='$NuGetApiKey'")
212238
& choco @chocoArgs
213239

214240
# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
215241
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
216242

217243
Update-JsonFile -Path "$env:SystemDrive\choco-setup\logs\nexus.json" -Properties @{
218244
NexusUri = "https://$($SubjectWithoutCn):8443"
219-
NexusRepo = $RepositoryUrl
245+
NexusRepo = $CoreRepositoryUrl
220246
ChocoUserPassword = $NexusPw
221247
}
222248

@@ -271,7 +297,7 @@ process {
271297
# Touch NOTHING below this line
272298
`$User = 'chocouser'
273299
`$SecurePassword = `$NexusUserPW | ConvertTo-SecureString -AsPlainText -Force
274-
`$RepositoryUrl = "https://`$(`$fqdn):8443/repository/ChocolateyInternal/index.json"
300+
`$RepositoryUrl = "https://`$(`$fqdn):8443/repository/ChocolateyCore/index.json"
275301
276302
`$credential = [pscredential]::new(`$user, `$securePassword)
277303

Start-C4bNexusSetup.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ process {
5959
Enable-NexusRealm -Realm 'NuGet API-Key Realm'
6060

6161
#Create Chocolatey repositories
62+
New-NexusNugetHostedRepository -Name ChocolateyCore -DeploymentPolicy Allow
6263
New-NexusNugetHostedRepository -Name ChocolateyInternal -DeploymentPolicy Allow
6364
New-NexusNugetHostedRepository -Name ChocolateyTest -DeploymentPolicy Allow
6465
New-NexusRawHostedRepository -Name choco-install -DeploymentPolicy Allow -ContentDisposition Attachment
@@ -68,11 +69,11 @@ process {
6869

6970
# Push all packages from previous steps to NuGet repo
7071
Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\packages" -Filter *.nupkg | ForEach-Object {
71-
choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force
72+
choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --apikey $NugetApiKey --force
7273
}
7374

7475
# Temporary workaround to reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
75-
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
76+
Remove-NexusRepositoryFolder -RepositoryName ChocolateyCore -Name v3
7677

7778
# Push latest ChocolateyInstall.ps1 to raw repo
7879
$ScriptDir = "$env:SystemDrive\choco-setup\files\scripts"
@@ -93,6 +94,9 @@ process {
9394
# Add ChocolateyInternal as a source repository
9495
choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1
9596

97+
# Add ChocolateyCore as a source repository
98+
choco source add -n 'ChocolateyCore' -s "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --priority 0 --admin-only
99+
96100
# Install a non-IE browser for browsing the Nexus web portal.
97101
if (-not (Test-Path 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')) {
98102
Write-Host "Installing Microsoft Edge, to allow viewing the Nexus site"

jenkins/Internalize packages from the Community Repository/builds/legacyIds

Whitespace-only changes.

jenkins/Internalize packages from the Community Repository/builds/permalinks

Lines changed: 0 additions & 2 deletions
This file was deleted.

jenkins/Internalize packages from the Community Repository/nextBuildNumber

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.1" encoding="UTF-8"?><flow-definition plugin="[email protected]">
2+
<actions/>
3+
<description>Automatically update any out of date packages in the ChocolateyCore repository from the Licensed and Community Repositories</description>
4+
<keepDependencies>false</keepDependencies>
5+
<properties>
6+
<org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty/>
7+
<hudson.model.ParametersDefinitionProperty>
8+
<parameterDefinitions>
9+
<hudson.model.StringParameterDefinition>
10+
<name>P_LOCAL_REPO_URL</name>
11+
<description>Internal core repository.</description>
12+
<defaultValue>https://{{hostname}}:8443/repository/ChocolateyCore/index.json</defaultValue>
13+
<trim>true</trim>
14+
</hudson.model.StringParameterDefinition>
15+
<hudson.model.StringParameterDefinition>
16+
<name>P_REMOTE_REPO_URL</name>
17+
<description>Remote repositories containing updated package versions.</description>
18+
<defaultValue>https://licensedpackages.chocolatey.org/api/v2/;https://community.chocolatey.org/api/v2/</defaultValue>
19+
<trim>true</trim>
20+
</hudson.model.StringParameterDefinition>
21+
<hudson.model.PasswordParameterDefinition>
22+
<name>P_LOCAL_REPO_API_KEY</name>
23+
<description>API key for the internal core repository where updated packages will be pushed.</description>
24+
<defaultValue>{{NugetApiKey}}</defaultValue>
25+
</hudson.model.PasswordParameterDefinition>
26+
</parameterDefinitions>
27+
</hudson.model.ParametersDefinitionProperty>
28+
</properties>
29+
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="[email protected]">
30+
<script>node {
31+
powershell '''
32+
Set-Location (Join-Path "$env:SystemDrive" -ChildPath 'scripts')
33+
.\\Get-UpdatedPackage.ps1 -LocalRepo $env:P_LOCAL_REPO_URL `
34+
-LocalRepoApiKey $env:P_LOCAL_REPO_API_KEY `
35+
-RemoteRepo $env:P_REMOTE_REPO_URL `
36+
-Verbose
37+
'''
38+
}</script>
39+
<sandbox>true</sandbox>
40+
</definition>
41+
<triggers/>
42+
<disabled>false</disabled>
43+
</flow-definition>

jenkins/Update production repository/builds/legacyIds

Whitespace-only changes.

jenkins/Update production repository/builds/permalinks

Lines changed: 0 additions & 6 deletions
This file was deleted.

jenkins/Update production repository/nextBuildNumber

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)