Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Jenkins Pushing and ClientSetup #287

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions Set-SslSecurity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ process {
Write-Host "Nexus is ready!"

Invoke-Choco source remove --name="'ChocolateyInternal'"
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"

# Build Credential Object, Connect to Nexus
$securePw = (Get-Content 'C:\programdata\sonatype-work\nexus3\admin.password') | ConvertTo-SecureString -AsPlainText -Force
Expand Down Expand Up @@ -156,34 +155,39 @@ process {
Password = ($NexusPw | ConvertTo-SecureString -AsPlainText -Force)
FirstName = 'Choco'
LastName = 'User'
EmailAddress = 'chocouser@foo.com'
EmailAddress = 'chocouser@example.com'
Status = 'Active'
Roles = 'chocorole'
}
New-NexusUser @UserParams
}

$ChocoArgs = @(
'source',
'add',
"--name='ChocolateyInternal'",
"--source='$RepositoryUrl'",
'--priority=1',
"--user='chocouser'",
"--password='$NexusPw'"
)
& Invoke-Choco @ChocoArgs

# Update Repository API key
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
& Invoke-Choco @chocoArgs

# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
# Update all sources with credentials and the new path
foreach ($Repository in Get-NexusRepository -Format nuget | Where-Object Type -eq 'hosted') {
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/$($Repository.Name)/index.json"

$ChocoArgs = @(
'source',
'add',
"--name='$($Repository.Name)'",
"--source='$RepositoryUrl'",
'--priority=1',
"--user='chocouser'",
"--password='$NexusPw'"
)
& Invoke-Choco @ChocoArgs

# Update Repository API key
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
& Invoke-Choco @chocoArgs

# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
Remove-NexusRepositoryFolder -RepositoryName $Repository.Name -Name v3
}

Update-Clixml -Properties @{
NexusUri = "https://$($SubjectWithoutCn):8443"
NexusRepo = $RepositoryUrl
NexusRepo = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
ChocoUserPassword = $NexusPw
}

Expand Down
6 changes: 5 additions & 1 deletion Start-C4bNexusSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ process {
# Add ChocolateyInternal as a source repository
Invoke-Choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1

#Remove Local Chocolatey Setup Source
# Add ChocolateyTest as a source repository, to enable authenticated pushing
Invoke-Choco source add -n 'ChocolateyTest' -s "$((Get-NexusRepository -Name 'ChocolateyTest').url)/index.json"
Invoke-Choco source disable -n 'ChocolateyTest'

# Remove Local Chocolatey Setup Source
$chocoArgs = @('source', 'remove', '--name="LocalChocolateySetup"')
& Invoke-Choco @chocoArgs

Expand Down
4 changes: 2 additions & 2 deletions scripts/ClientSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ if ($Credential) {

# Find the latest version of Chocolatey, if a version was not specified
$NupkgUrl = if (-not $ChocolateyVersion) {
$QueryUrl = ($RepositoryUrl.TrimEnd('/index.json'), "v3/registration/Chocolatey/index.json") -join '/'
$QueryUrl = (($RepositoryUrl -replace '/index\.json$'), "v3/registration/Chocolatey/index.json") -join '/'
$Result = $webClient.DownloadString($QueryUrl) | ConvertFrom-Json
$Result.items.items[-1].packageContent
} else {
# Otherwise, assume the URL
"$($RepositoryUrl.TrimEnd('/index.json'))/v3/content/chocolatey/$($ChocolateyVersion)/chocolatey.$($ChocolateyVersion).nupkg"
"$($RepositoryUrl -replace '/index\.json$')/v3/content/chocolatey/$($ChocolateyVersion)/chocolatey.$($ChocolateyVersion).nupkg"
}

# Download the NUPKG
Expand Down
Loading