From 07553f6c30f54b45a0548595858b377dc6841f91 Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Mon, 9 Dec 2024 08:40:09 +0000 Subject: [PATCH] use the nexus api to create the adhoc-package raw repository --- README.md | 2 +- provision/provision-nexus.sh | 26 +++++++++++++++++++ .../src/main/groovy/provision.groovy | 7 ----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5e96ca6..51904c2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/provision/provision-nexus.sh b/provision/provision-nexus.sh index 8db1ab3..02dce78 100644 --- a/provision/provision-nexus.sh +++ b/provision/provision-nexus.sh @@ -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 diff --git a/provision/provision-nexus/src/main/groovy/provision.groovy b/provision/provision-nexus/src/main/groovy/provision.groovy index d271407..2814ea0 100644 --- a/provision/provision-nexus/src/main/groovy/provision.groovy +++ b/provision/provision-nexus/src/main/groovy/provision.groovy @@ -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')