@@ -120,7 +120,6 @@ process {
120
120
Write-Host " Nexus is ready!"
121
121
122
122
Invoke-Choco source remove -- name= " 'ChocolateyInternal'"
123
- $RepositoryUrl = " https://${SubjectWithoutCn} :8443/repository/ChocolateyInternal/index.json"
124
123
125
124
# Build Credential Object, Connect to Nexus
126
125
$securePw = (Get-Content ' C:\programdata\sonatype-work\nexus3\admin.password' ) | ConvertTo-SecureString - AsPlainText - Force
@@ -156,34 +155,39 @@ process {
156
155
Password = ($NexusPw | ConvertTo-SecureString - AsPlainText - Force)
157
156
FirstName = ' Choco'
158
157
LastName = ' User'
159
- EmailAddress = ' chocouser@foo .com'
158
+ EmailAddress = ' chocouser@example .com'
160
159
Status = ' Active'
161
160
Roles = ' chocorole'
162
161
}
163
162
New-NexusUser @UserParams
164
163
}
165
164
166
- $ChocoArgs = @ (
167
- ' source' ,
168
- ' add' ,
169
- " --name='ChocolateyInternal'" ,
170
- " --source='$RepositoryUrl '" ,
171
- ' --priority=1' ,
172
- " --user='chocouser'" ,
173
- " --password='$NexusPw '"
174
- )
175
- & Invoke-Choco @ChocoArgs
176
-
177
- # Update Repository API key
178
- $chocoArgs = @ (' apikey' , " --source='$RepositoryUrl '" , " --api-key='$NuGetApiKey '" )
179
- & Invoke-Choco @chocoArgs
180
-
181
- # Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
182
- Remove-NexusRepositoryFolder - RepositoryName ChocolateyInternal - Name v3
165
+ # Update all sources with credentials and the new path
166
+ foreach ($Repository in Get-NexusRepository - Format nuget | Where-Object Type -eq ' hosted' ) {
167
+ $RepositoryUrl = " https://${SubjectWithoutCn} :8443/repository/$ ( $Repository.Name ) /index.json"
168
+
169
+ $ChocoArgs = @ (
170
+ ' source' ,
171
+ ' add' ,
172
+ " --name='$ ( $Repository.Name ) '" ,
173
+ " --source='$RepositoryUrl '" ,
174
+ ' --priority=1' ,
175
+ " --user='chocouser'" ,
176
+ " --password='$NexusPw '"
177
+ )
178
+ & Invoke-Choco @ChocoArgs
179
+
180
+ # Update Repository API key
181
+ $chocoArgs = @ (' apikey' , " --source='$RepositoryUrl '" , " --api-key='$NuGetApiKey '" )
182
+ & Invoke-Choco @chocoArgs
183
+
184
+ # Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
185
+ Remove-NexusRepositoryFolder - RepositoryName $Repository.Name - Name v3
186
+ }
183
187
184
188
Update-Clixml - Properties @ {
185
189
NexusUri = " https://$ ( $SubjectWithoutCn ) :8443"
186
- NexusRepo = $RepositoryUrl
190
+ NexusRepo = " https:// ${SubjectWithoutCn} :8443/repository/ChocolateyInternal/index.json "
187
191
ChocoUserPassword = $NexusPw
188
192
}
189
193
0 commit comments