use the nexus api to create the adhoc-package raw repository

This commit is contained in:
Rui Lopes 2024-12-09 08:40:09 +00:00
parent efe4608194
commit 07553f6c30
No known key found for this signature in database
3 changed files with 27 additions and 8 deletions

View File

@ -3,9 +3,9 @@ This is a Vagrant Environment for a [Nexus Repository OSS](https://github.com/so
This will:
* Configure Nexus through the API.
* Create the `adhoc-package` repository.
* Configure the NuGet `nuget-hosted` repository to accept pushing with an API key.
* Configure Nexus through Groovy scripts.
* Create the `adhoc-package` repository.
* Create the `npm-group`, `npm-hosted` and `npmjs.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.

View File

@ -166,6 +166,31 @@ bash /vagrant/provision/execute-provision.groovy-script.sh
# set the api credentials.
api_auth="admin:admin"
# create the adhoc-package raw repository.
# NB this repository can host any type of artifact, so we disable strictContentTypeValidation.
# see https://help.sonatype.com/display/NXRM3/Raw+Repositories+and+Maven+Sites#RawRepositoriesandMavenSites-UploadingFilestoHostedRawRepositories
http \
--check-status \
--auth "$api_auth" \
POST \
https://$nexus_domain/service/rest/v1/repositories/raw/hosted \
<<'EOF'
{
"name": "adhoc-package",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": false,
"writePolicy": "allow_once"
},
"component": {
"proprietaryComponents": true
}
}
EOF
# create the pypi-hosted repository.
http \
--check-status \
@ -187,6 +212,7 @@ http \
}
EOF
# configure nexus ldap with a groovy script.
if [ "$config_authentication" = 'ldap' ]; then
bash /vagrant/provision/execute-provision-ldap.groovy-script.sh

View File

@ -25,13 +25,6 @@ capabilityRegistry.all.findAll {it.context().type().toString().startsWith("Outre
// ]}
//])
// create a raw repository backed by the default blob store.
// NB this repository can host any type of artifact, so we disable strictContentTypeValidation.
// see https://github.com/sonatype/nexus-book-examples/blob/nexus-3.x/scripting/complex-script/rawRepositories.groovy
// see https://help.sonatype.com/display/NXRM3/Raw+Repositories+and+Maven+Sites#RawRepositoriesandMavenSites-UploadingFilestoHostedRawRepositories
repository.createRawHosted("adhoc-package", "default", false, WritePolicy.ALLOW_ONCE)
// create a apt repository backed by the default blob store.
// see https://help.sonatype.com/repomanager3/formats/apt-repositories
pgpPrivateKey = new File('/vagrant/shared/apt-hosted-private.key').getText('UTF-8')