use the nexus api to create the chocolatey nuget repositories

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

View File

@ -7,9 +7,9 @@ This will:
* Create the `apt-hosted` repository. * Create the `apt-hosted` 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 `powershell-group`, `powershell-hosted` and `powershellgallery.com-proxy` repositories. * Create the `powershell-group`, `powershell-hosted` and `powershellgallery.com-proxy` repositories.
* Create the `chocolatey-group`, `chocolatey-hosted` and `chocolatey.org-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.
* Configure Nexus through Groovy scripts. * Configure Nexus through Groovy scripts.
* Create the `chocolatey-group`, `chocolatey-hosted` and `chocolatey.org-proxy` repositories.
* 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.
* Setup an Active Directory LDAP user authentication source (when `config_authentication='ldap'` is set inside the `provision-nexus.sh` file). * Setup an Active Directory LDAP user authentication source (when `config_authentication='ldap'` is set inside the `provision-nexus.sh` file).

View File

@ -406,6 +406,92 @@ http \
} }
} }
EOF EOF
# create the chocolatey-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": "chocolatey-hosted",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true,
"writePolicy": "allow_once"
},
"component": {
"proprietaryComponents": true
}
}
EOF
# create a chocolatey.org-proxy nuget 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": "chocolatey.org-proxy",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true
},
"proxy": {
"remoteUrl": "https://chocolatey.org/api/v2/",
"contentMaxAge": 1440,
"metadataMaxAge": 1440
},
"nugetProxy": {
"queryCacheItemMaxAge": 3600,
"nugetVersion": "V2"
},
"negativeCache": {
"enabled": true,
"timeToLive": 1440
},
"httpClient": {
"blocked": false,
"autoBlock": true
}
}
EOF
# create the chocolatey-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": "chocolatey-group",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true
},
"group": {
"memberNames": [
"chocolatey-hosted",
"chocolatey.org-proxy"
]
}
}
EOF
# configure nexus ldap with a groovy script. # configure nexus ldap with a groovy script.
if [ "$config_authentication" = 'ldap' ]; then if [ "$config_authentication" = 'ldap' ]; then
bash /vagrant/provision/execute-provision-ldap.groovy-script.sh 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 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.
// see https://help.sonatype.com/repomanager3/formats/nuget-repositories
config = repository.createNugetProxy("chocolatey.org-proxy", "https://chocolatey.org/api/v2/", "default").configuration.copy()
config.attributes.nugetProxy.nugetVersion = "V2"
repository.repositoryManager.update(config)
// create a chocolatey group repository that merges the chocolatey-host and chocolatey.org-proxy together.
repository.createNugetGroup("chocolatey-group", ["chocolatey-hosted", "chocolatey.org-proxy"], "default")
// create a docker registry repository backed by the default blob store. // create a docker registry repository backed by the default blob store.
repository.createDockerHosted("docker-hosted", 6003, null, "default", true, true, WritePolicy.ALLOW, true) repository.createDockerHosted("docker-hosted", 6003, null, "default", true, true, WritePolicy.ALLOW, true)
// create a docker proxy repository backed by the default blob store. // create a docker proxy repository backed by the default blob store.