use the nexus api to create the powershell nuget repositories

This commit is contained in:
Rui Lopes 2024-12-09 08:40:41 +00:00
parent 996c7b692e
commit 4811051ea3
No known key found for this signature in database
3 changed files with 83 additions and 12 deletions

View File

@ -6,10 +6,10 @@ This will:
* Create the `adhoc-package` repository.
* Create the `apt-hosted` repository.
* Create the `npm-group`, `npm-hosted` and `npmjs.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 Nexus through Groovy scripts.
* Create the `chocolatey-group`, `chocolatey-hosted` and `chocolatey.org-proxy` repositories.
* Create the `powershell-group`, `powershell-hosted` and `powershellgallery.com-proxy` repositories.
* Schedule a task to remove the old snapshots from the `maven-snapshots` repository.
* Create users and a custom `deployer` role.
* Setup an Active Directory LDAP user authentication source (when `config_authentication='ldap'` is set inside the `provision-nexus.sh` file).

View File

@ -324,6 +324,88 @@ http \
EOF
# create the powershell-hosted nuget hosted repository.
# see https://help.sonatype.com/en/nuget-repositories.html
http \
--check-status \
--auth "$api_auth" \
POST \
https://$nexus_domain/service/rest/v1/repositories/nuget/hosted \
<<'EOF'
{
"name": "powershell-hosted",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true,
"writePolicy": "allow_once"
},
"component": {
"proprietaryComponents": true
}
}
EOF
# create a powershellgallery.com-proxy powershell proxy repository.
# see https://help.sonatype.com/en/nuget-repositories.html
http \
--check-status \
--auth "$api_auth" \
POST \
https://$nexus_domain/service/rest/v1/repositories/nuget/proxy \
<<'EOF'
{
"name": "powershellgallery.com-proxy",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true
},
"proxy": {
"remoteUrl": "https://www.powershellgallery.com/api/v2/",
"contentMaxAge": 1440,
"metadataMaxAge": 1440
},
"nugetProxy": {
"queryCacheItemMaxAge": 3600,
"nugetVersion": "V2"
},
"negativeCache": {
"enabled": true,
"timeToLive": 1440
},
"httpClient": {
"blocked": false,
"autoBlock": true
}
}
EOF
# create the powershell-group nuget group repository.
# see https://help.sonatype.com/en/nuget-repositories.html
http \
--check-status \
--auth "$api_auth" \
POST \
https://$nexus_domain/service/rest/v1/repositories/nuget/group \
<<'EOF'
{
"name": "powershell-group",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true
},
"group": {
"memberNames": [
"powershell-hosted",
"powershellgallery.com-proxy"
]
}
}
EOF
# configure nexus ldap with a groovy script.
if [ "$config_authentication" = 'ldap' ]; then
bash /vagrant/provision/execute-provision-ldap.groovy-script.sh

View File

@ -26,17 +26,6 @@ capabilityRegistry.all.findAll {it.context().type().toString().startsWith("Outre
//])
// 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/repomanager3/formats/nuget-repositories
config = repository.createNugetProxy("powershellgallery.com-proxy", "https://www.powershellgallery.com/api/v2/", "default").configuration.copy()
config.attributes.nugetProxy.nugetVersion = "V2"
repository.repositoryManager.update(config)
// 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.
repository.createNugetHosted("chocolatey-hosted", "default", true, WritePolicy.ALLOW_ONCE)
// create a chocolatey proxy repository backed by the default blob store.