Skip to content

Commit d784bb1

Browse files
committed
(#230) Adds ChocolateyCore Repository and Jenkins Job
- Adds ChocolateyCore repo as main repo for core packages - Adds callout to new ChocolateyCore repository Remove See It In Action section as video is outdated Fixup spelling/grammer - Adds new Update ChocolateyCore Repository Jenkins Job - Add test to check for new Jenkins job
1 parent 3130711 commit d784bb1

File tree

11 files changed

+123
-35
lines changed

11 files changed

+123
-35
lines changed

README.md

Lines changed: 10 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,14 @@ 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. **NuGet V3 Repository Server App (Nexus)**: Chocolatey works best with a NuGet V3 repository. This application 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 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.
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+
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.
4545

4646
## Requirements
4747

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

6363
1. Install all Windows Updates.
6464

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

6767
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.
6868

@@ -120,9 +120,11 @@ Below are the minimum requirements for setting up your C4B server via this guide
120120
> <ul class="list-style-type-disc">
121121
> <li>Installs Sonatype Nexus Repository Manager OSS instance</li>
122122
> <li>Cleans up all demo repositories on Nexus</li>
123+
> <li>Creates a "ChocolateyCore" NuGet repository</li>
123124
> <li>Creates a "ChocolateyInternal" NuGet repository</li>
124125
> <li>Creates a "ChocolateyTest" NuGet repository</li>
125126
> <li>Creates a "choco-install" raw repository</li>
127+
> <li>Sets up "ChocolateyCore" on C4B Server as source, with API key</li>
126128
> <li>Sets up "ChocolateyInternal" on C4B Server as source, with API key</li>
127129
> <li>Adds firewall rule for repository access</li>
128130
> <li>Installs MS Edge, and disables first-run experience</li>
@@ -177,7 +179,7 @@ Below are the minimum requirements for setting up your C4B server via this guide
177179
.\Set-SslSecurity.ps1
178180
```
179181
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:
182+
**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:
181183
182184
```powershell
183185
Set-Location "$env:SystemDrive\choco-setup\files"
@@ -189,7 +191,7 @@ Below are the minimum requirements for setting up your C4B server via this guide
189191
> :memo: **NOTE**
190192
> 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.
191193
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:
194+
**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:
193195
194196
```powershell
195197
Set-Location "$env:SystemDrive\choco-setup\files"
@@ -272,9 +274,3 @@ Below are the minimum requirements for setting up your C4B server via this guide
272274
Congratulations! If you followed all the steps detailed above, you should now have a fully functioning Chocolatey for Business implementation deployed in your environment.
273275
274276
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
@@ -57,6 +57,7 @@ process {
5757
Enable-NexusRealm -Realm 'NuGet API-Key Realm'
5858

5959
#Create Chocolatey repositories
60+
New-NexusNugetHostedRepository -Name ChocolateyCore -DeploymentPolicy Allow
6061
New-NexusNugetHostedRepository -Name ChocolateyInternal -DeploymentPolicy Allow
6162
New-NexusNugetHostedRepository -Name ChocolateyTest -DeploymentPolicy Allow
6263
New-NexusRawHostedRepository -Name choco-install -DeploymentPolicy Allow -ContentDisposition Attachment
@@ -66,11 +67,11 @@ process {
6667

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

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

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

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

jenkins/Update ChocolateyCore Repository/builds/legacyIds

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lastFailedBuild -1
2+
lastSuccessfulBuild -1
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>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

jenkins/Update production repository/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
</hudson.model.StringParameterDefinition>
2626
</parameterDefinitions>
2727
</hudson.model.ParametersDefinitionProperty>
28-
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
28+
</properties>
29+
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
2930
<triggers>
3031
<jenkins.triggers.ReverseBuildTrigger>
3132
<spec/>
@@ -39,7 +40,6 @@
3940
</jenkins.triggers.ReverseBuildTrigger>
4041
</triggers>
4142
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
42-
</properties>
4343
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="[email protected]">
4444
<script> node {
4545
powershell '''

scripts/ClientSetup.ps1

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ param(
99
[Parameter()]
1010
[Alias('Url')]
1111
[string]
12-
$RepositoryUrl = 'https://{{hostname}}:8443/repository/ChocolateyInternal/index.json',
12+
$RepositoryUrl = 'https://{{hostname}}:8443/repository/ChocolateyCore/index.json',
1313

1414
# The credential necessary to access the internal Nexus repository. This can
1515
# be ignored if Anonymous authentication is enabled.
@@ -86,13 +86,13 @@ if ($Credential) {
8686
$NupkgUrl = if (-not $ChocolateyVersion) {
8787
$QueryString = "((Id eq 'chocolatey') and (not IsPrerelease)) and IsLatestVersion"
8888
$Query = 'Packages()?$filter={0}' -f [uri]::EscapeUriString($queryString)
89-
$QueryUrl = ($RepositoryUrl.TrimEnd('/index.json'), $Query) -join '/'
89+
$QueryUrl = ($RepositoryUrl.Replace('/index.json',''), $Query) -join '/'
9090

9191
[xml]$result = $webClient.DownloadString($QueryUrl)
9292
$result.feed.entry.content.src
9393
} else {
9494
# Otherwise, assume the URL
95-
"$($RepositoryUrl.TrimEnd('/index.json'))/chocolatey/$($ChocolateyVersion)"
95+
"$($RepositoryUrl.Replace('/index.json',''))/chocolatey/$($ChocolateyVersion)"
9696
}
9797

9898
# Download the NUPKG
@@ -112,21 +112,28 @@ choco config set cacheLocation $env:ChocolateyInstall\choco-cache
112112
choco config set commandExecutionTimeoutSeconds 14400
113113

114114
if ($InternetEnabled) {
115-
choco source add --name="'ChocolateyInternal'" --source="'$RepositoryUrl'" --allow-self-service --user="'$($Credential.UserName)'" --password="'$($Credential.GetNetworkCredential().Password)'" --priority=1
115+
choco source add --name="'ChocolateyCore'" --source="'$RepositoryUrl'" --allow-self-service --admin-only --user="'$($Credential.UserName)'" --password="'$($Credential.GetNetworkCredential().Password)'" --priority=0
116116
}
117117
else {
118-
choco source add --name="'ChocolateyInternal'" --source="'$RepositoryUrl'" --allow-self-service --priority=1
118+
choco source add --name="'ChocolateyCore'" --source="'$RepositoryUrl'" --allow-self-service --admin-only --priority=0
119+
}
120+
121+
if ($InternetEnabled) {
122+
choco source add --name="'ChocolateyInternal'" --source="'$($RepositoryUrl -replace '(?<=/)ChocolateyCore(/index.json)?', 'ChocolateyInternal$1')'" --allow-self-service --user="'$($Credential.UserName)'" --password="'$($Credential.GetNetworkCredential().Password)'" --priority=1
123+
}
124+
else {
125+
choco source add --name="'ChocolateyInternal'" --source="'$($RepositoryUrl -replace '(?<=/)ChocolateyCore(/index.json)?', 'ChocolateyInternal$1')'" --allow-self-service --priority=1
119126
}
120127

121128
choco source disable --name="'Chocolatey'"
122129
choco source disable --name="'chocolatey.licensed'"
123130

124-
choco upgrade chocolatey-license -y --source="'ChocolateyInternal'"
125-
choco upgrade chocolatey.extension -y --params="'/NoContextMenu'" --source="'ChocolateyInternal'" --no-progress
126-
choco upgrade chocolateygui -y --source="'ChocolateyInternal'" --no-progress
127-
choco upgrade chocolateygui.extension -y --source="'ChocolateyInternal'" --no-progress
131+
choco upgrade chocolatey-license -y --source="'ChocolateyCore'"
132+
choco upgrade chocolatey.extension -y --params="'/NoContextMenu'" --source="'ChocolateyCore'" --no-progress
133+
choco upgrade chocolateygui -y --source="'ChocolateyCore'" --no-progress
134+
choco upgrade chocolateygui.extension -y --source="'ChocolateyCore'" --no-progress
128135

129-
choco upgrade chocolatey-agent -y --source="'ChocolateyInternal'"
136+
choco upgrade chocolatey-agent -y --source="'ChocolateyCore'"
130137

131138
# Chocolatey Package Upgrade Resilience
132139
choco feature enable --name="'excludeChocolateyPackagesDuringUpgradeAll'"

tests/jenkins.test.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ Describe "Jenkins Configuration" {
6464
It "'Update test repository from Chocolatey Community Repository' is present" {
6565
'Update test repository from Chocolatey Community Repository' -in $jobs | Should -Be $true
6666
}
67+
68+
It "'Update ChocolateyCore Repository' is present" {
69+
'Update ChocolateyCore Repository' -in $jobs | Should -Be $true
70+
}
6771
}
6872

6973
Context "Web Interface" {

0 commit comments

Comments
 (0)