Skip to content

Commit 5ca3184

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 2b0d360 commit 5ca3184

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: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ process {
137137
Write-Host "Nexus is ready!"
138138

139139
Invoke-Choco source remove --name="'ChocolateyInternal'"
140-
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
140+
$InternalRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
141+
142+
Invoke-Choco source remove --name="'ChocolateyCore'"
143+
$CoreRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyCore/index.json"
141144

142145
# Build Credential Object, Connect to Nexus
143146
$securePw = (Get-Content 'C:\programdata\sonatype-work\nexus3\admin.password') | ConvertTo-SecureString -AsPlainText -Force
@@ -185,35 +188,58 @@ process {
185188
'source',
186189
'add',
187190
"--name='ChocolateyInternal'",
188-
"--source='$RepositoryUrl'",
191+
"--source='$InternalRepositoryUrl'",
189192
'--priority=1',
190193
"--user='chocouser'",
191194
"--password='$NexusPw'"
192195
)
193-
& Invoke-Choco @ChocoArgs
196+
& choco @ChocoArgs
197+
198+
$ChocoArgs = @(
199+
'source',
200+
'add',
201+
"--name='ChocolateyCore'",
202+
"--source='$CoreRepositoryUrl'",
203+
'--priority=0',
204+
"--user='chocouser'",
205+
"--password='$NexusPw'"
206+
)
207+
& choco @ChocoArgs
194208
}
195209

196210
else {
197211
$ChocoArgs = @(
198212
'source',
199213
'add',
200214
"--name='ChocolateyInternal'",
201-
"--source='$RepositoryUrl'",
215+
"--source='$InternalRepositoryUrl'",
202216
'--priority=1'
203217
)
204218
& Invoke-Choco @ChocoArgs
219+
220+
$ChocoArgs = @(
221+
'source',
222+
'add',
223+
"--name='ChocolateyCore'",
224+
"--source='$CoreRepositoryUrl'",
225+
'--priority=0'
226+
)
227+
& Invoke-Choco @ChocoArgs
205228
}
206229

207230
# Update Repository API key
208-
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
231+
$chocoArgs = @('apikey', "--source='$InternalRepositoryUrl'", "--api-key='$NuGetApiKey'")
232+
& Invoke-Choco @chocoArgs
233+
234+
$chocoArgs = @('apikey', "--source='$CoreRepositoryUrl'", "--api-key='$NuGetApiKey'")
209235
& Invoke-Choco @chocoArgs
210236

211237
# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
212238
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
213239

214240
Update-Clixml -Properties @{
215241
NexusUri = "https://$($SubjectWithoutCn):8443"
216-
NexusRepo = $RepositoryUrl
242+
NexusRepo = $CoreRepositoryUrl
217243
ChocoUserPassword = $NexusPw
218244
}
219245

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

Start-C4bNexusSetup.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ process {
4747
Enable-NexusRealm -Realm 'NuGet API-Key Realm'
4848

4949
#Create Chocolatey repositories
50+
New-NexusNugetHostedRepository -Name ChocolateyCore -DeploymentPolicy Allow
5051
New-NexusNugetHostedRepository -Name ChocolateyInternal -DeploymentPolicy Allow
5152
New-NexusNugetHostedRepository -Name ChocolateyTest -DeploymentPolicy Allow
5253
New-NexusRawHostedRepository -Name choco-install -DeploymentPolicy Allow -ContentDisposition Attachment
@@ -56,11 +57,11 @@ process {
5657

5758
# Push all packages from previous steps to NuGet repo
5859
Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\packages" -Filter *.nupkg | ForEach-Object {
59-
Invoke-Choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force
60+
Invoke-Choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --apikey $NugetApiKey --force
6061
}
6162

6263
# Temporary workaround to reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
63-
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
64+
Remove-NexusRepositoryFolder -RepositoryName ChocolateyCore -Name v3
6465

6566
# Push latest ChocolateyInstall.ps1 to raw repo
6667
$ScriptDir = "$env:SystemDrive\choco-setup\files\scripts"
@@ -84,10 +85,13 @@ process {
8485
# Add ChocolateyInternal as a source repository
8586
Invoke-Choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1
8687

87-
#Remove Local Chocolatey Setup Source
88+
# Remove Local Chocolatey Setup Source
8889
$chocoArgs = @('source', 'remove', '--name="LocalChocolateySetup"')
8990
& Invoke-Choco @chocoArgs
9091

92+
# Add ChocolateyCore as a source repository
93+
Invoke-Choco source add -n 'ChocolateyCore' -s "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --priority 0 --admin-only
94+
9195
# Install a non-IE browser for browsing the Nexus web portal.
9296
if (-not (Test-Path 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')) {
9397
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)