@@ -120,7 +120,6 @@ process {
120120 Write-Host " Nexus is ready!"
121121
122122 Invoke-Choco source remove -- name= " 'ChocolateyInternal'"
123- $RepositoryUrl = " https://${SubjectWithoutCn} :8443/repository/ChocolateyInternal/index.json"
124123
125124 # Build Credential Object, Connect to Nexus
126125 $securePw = (Get-Content ' C:\programdata\sonatype-work\nexus3\admin.password' ) | ConvertTo-SecureString - AsPlainText - Force
@@ -156,34 +155,39 @@ process {
156155 Password = ($NexusPw | ConvertTo-SecureString - AsPlainText - Force)
157156 FirstName = ' Choco'
158157 LastName = ' User'
159- EmailAddress = ' chocouser@foo .com'
158+ EmailAddress = ' chocouser@example .com'
160159 Status = ' Active'
161160 Roles = ' chocorole'
162161 }
163162 New-NexusUser @UserParams
164163 }
165164
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+ }
183187
184188 Update-Clixml - Properties @ {
185189 NexusUri = " https://$ ( $SubjectWithoutCn ) :8443"
186- NexusRepo = $RepositoryUrl
190+ NexusRepo = " https:// ${SubjectWithoutCn} :8443/repository/ChocolateyInternal/index.json "
187191 ChocoUserPassword = $NexusPw
188192 }
189193
0 commit comments