provision powershell repositories
This commit is contained in:
parent
46fa1b44ab
commit
da1c31e756
|
|
@ -6,6 +6,7 @@ This will:
|
||||||
* Create the `adhoc-package` repository.
|
* Create the `adhoc-package` repository.
|
||||||
* Create the `npm-group`, `npm-hosted` and `npmjs.org-proxy` repositories.
|
* Create the `npm-group`, `npm-hosted` and `npmjs.org-proxy` repositories.
|
||||||
* Create the `chocolatey-group`, `chocolatey-hosted` and `chocolatey.org-proxy` repositories.
|
* Create the `chocolatey-group`, `chocolatey-hosted` and `chocolatey.org-proxy` repositories.
|
||||||
|
* Create the `powershell-group`, `powershell-hosted` and `powershellgallery.com-proxy` repositories.
|
||||||
* Configure the NuGet `nuget-hosted` repository to accept pushing with an API key.
|
* Configure the NuGet `nuget-hosted` repository to accept pushing with an API key.
|
||||||
* Schedule a task to remove the old snapshots from the `maven-snapshots` repository.
|
* Schedule a task to remove the old snapshots from the `maven-snapshots` repository.
|
||||||
* Create users and a custom `deployer` role.
|
* Create users and a custom `deployer` role.
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,6 @@ Vagrant.configure(2) do |config|
|
||||||
config.vm.provision :shell, inline: "echo '#{nexus_ip} #{nexus_domain}' | Out-File -Encoding Ascii -Append c:/Windows/System32/drivers/etc/hosts"
|
config.vm.provision :shell, inline: "echo '#{nexus_ip} #{nexus_domain}' | Out-File -Encoding Ascii -Append c:/Windows/System32/drivers/etc/hosts"
|
||||||
config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['provision-base.ps1', nexus_domain]
|
config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['provision-base.ps1', nexus_domain]
|
||||||
config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-chocolatey-repository.ps1', nexus_domain]
|
config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-chocolatey-repository.ps1', nexus_domain]
|
||||||
|
config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-powershell-repository.ps1', nexus_domain]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,15 @@ repository.createNpmProxy("npmjs.org-proxy", "https://registry.npmjs.org", "defa
|
||||||
repository.createNpmGroup("npm-group", ["npm-hosted", "npmjs.org-proxy"], "default")
|
repository.createNpmGroup("npm-group", ["npm-hosted", "npmjs.org-proxy"], "default")
|
||||||
|
|
||||||
|
|
||||||
|
// create a powershell repository backed by the default blob store.
|
||||||
|
repository.createNugetHosted("powershell-hosted", "default", true, WritePolicy.ALLOW_ONCE)
|
||||||
|
// create a powershell proxy repository backed by the default blob store.
|
||||||
|
// see https://help.sonatype.com/display/NXRM3/.NET+Package+Repositories+with+NuGet
|
||||||
|
repository.createNugetProxy("powershellgallery.com-proxy", "https://www.powershellgallery.com/api/v2/", "default")
|
||||||
|
// create a powershell group repository that merges the powershell-host and powershellgallery.com-proxy together.
|
||||||
|
repository.createNugetGroup("powershell-group", ["powershell-hosted", "powershellgallery.com-proxy"], "default")
|
||||||
|
|
||||||
|
|
||||||
// create a chocolatey repository backed by the default blob store.
|
// create a chocolatey repository backed by the default blob store.
|
||||||
repository.createNugetHosted("chocolatey-hosted", "default", true, WritePolicy.ALLOW_ONCE)
|
repository.createNugetHosted("chocolatey-hosted", "default", true, WritePolicy.ALLOW_ONCE)
|
||||||
// create a chocolatey proxy repository backed by the default blob store.
|
// create a chocolatey proxy repository backed by the default blob store.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
param(
|
||||||
|
[string]$nexusDomain = 'nexus.example.com'
|
||||||
|
)
|
||||||
|
|
||||||
|
# NB this is needed to answer 'Yes' to all PS related questions.
|
||||||
|
$ConfirmPreference = 'None'
|
||||||
|
|
||||||
|
Write-Host 'Default PowerShell sources:'
|
||||||
|
Get-PSRepository
|
||||||
|
|
||||||
|
Write-Host 'Configuring PowerShell to only use the nexus server...'
|
||||||
|
Get-PSRepository | Unregister-PSRepository
|
||||||
|
Install-PackageProvider NuGet -Force
|
||||||
|
Register-PSRepository `
|
||||||
|
-Name nexus `
|
||||||
|
-SourceLocation https://$nexusDomain/repository/powershell-group/ `
|
||||||
|
-PublishLocation https://$nexusDomain/repository/powershell-hosted/ `
|
||||||
|
-InstallationPolicy Trusted
|
||||||
|
|
||||||
|
Write-Host 'Current PowerShell sources:'
|
||||||
|
Get-PSRepository
|
||||||
|
|
||||||
|
Write-Host 'Installing the Sql Server module from the nexus server...'
|
||||||
|
Install-Module SqlServer
|
||||||
|
|
||||||
|
Write-Host 'Installing nuget and configuring PowerShellGet to use it...'
|
||||||
|
choco install -y nuget.commandline
|
||||||
|
$psGetNugetPath = 'C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe'
|
||||||
|
mkdir (Split-Path -Parent $psGetNugetPath) | Out-Null
|
||||||
|
New-Item `
|
||||||
|
-ItemType SymbolicLink `
|
||||||
|
-Path $psGetNugetPath `
|
||||||
|
-Target 'C:\ProgramData\chocolatey\lib\NuGet.CommandLine\tools\NuGet.exe' `
|
||||||
|
| Out-Null
|
||||||
|
|
||||||
|
Write-Host 'Publishing the ExampleGreeter module into the nexus server...'
|
||||||
|
cd $env:TEMP
|
||||||
|
mkdir ExampleGreeter | Out-Null
|
||||||
|
Push-Location ExampleGreeter
|
||||||
|
Set-Content `
|
||||||
|
-Encoding Ascii `
|
||||||
|
ExampleGreeter.psm1 `
|
||||||
|
@'
|
||||||
|
function Write-Greeting([string]$name) {
|
||||||
|
"Hello $name!"
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
New-ModuleManifest `
|
||||||
|
ExampleGreeter.psd1 `
|
||||||
|
-ModuleVersion '1.0.0' `
|
||||||
|
-Author 'John Doe' `
|
||||||
|
-Description 'The Classic Hello World' `
|
||||||
|
-LicenseUri 'https://opensource.org/licenses/MIT' `
|
||||||
|
-ProjectUri 'https://example.com/ExampleGreeter' `
|
||||||
|
-RootModule 'ExampleGreeter.psm1' `
|
||||||
|
-Tags `
|
||||||
|
hello,
|
||||||
|
example `
|
||||||
|
-FunctionsToExport `
|
||||||
|
Write-Greeting `
|
||||||
|
-CmdletsToExport @() `
|
||||||
|
-VariablesToExport @() `
|
||||||
|
-AliasesToExport @()
|
||||||
|
Test-ModuleManifest ExampleGreeter.psd1
|
||||||
|
Publish-Module `
|
||||||
|
-Path . `
|
||||||
|
-Repository nexus `
|
||||||
|
-NuGetApiKey (Get-Content c:\vagrant\shared\jenkins-nuget-api-key)
|
||||||
|
Pop-Location
|
||||||
|
|
||||||
|
Write-Host 'Installing and using the ExampleGreeter module...'
|
||||||
|
Install-Module ExampleGreeter
|
||||||
|
Get-Module ExampleGreeter
|
||||||
|
Write-Greeting 'World'
|
||||||
Loading…
Reference in New Issue