Skip to content

Instantly share code, notes, and snippets.

@nblair
Created February 7, 2019 17:47
Show Gist options
  • Save nblair/64e1e33b2b4bde0700c36fe73b264d3e to your computer and use it in GitHub Desktop.
Save nblair/64e1e33b2b4bde0700c36fe73b264d3e to your computer and use it in GitHub Desktop.
Create a Google Cloud Blobstore with the Nexus Repository Manager Script API
import org.sonatype.nexus.blobstore.api.BlobStoreConfiguration
import org.sonatype.nexus.blobstore.api.BlobStoreManager
def blobStoreManager = container.lookup(BlobStoreManager.class.name)
blobStoreManager.create(new BlobStoreConfiguration(name: 'default', type: 'Google Cloud Storage',
attributes: [
'google cloud storage': [
bucket: "bucket-name-goes-here" // if you use an interpolated Groovy String here, make sure you call toString()
]
]))
@steven-edgar
Copy link

`import groovy.json.JsonSlurper
import org.sonatype.nexus.blobstore.api.BlobStoreConfiguration
import org.sonatype.nexus.blobstore.api.BlobStoreManager

parsed_args = new JsonSlurper().parseText(args)

existingBlobStore = blobStore.getBlobStoreManager().get(parsed_args.name)
if (existingBlobStore == null) {

def blobStoreManager = container.lookup(BlobStoreManager.class.name)
blobStoreManager.create(new BlobStoreConfiguration(name: parsed_args.name, type: 'Google Cloud Storage',
attributes: [
    'google cloud storage': [
        bucket: parsed_args.bucket,
        credential_file: parsed_args.credentials
    ]
]))

}
`

@nblair
Copy link
Author

nblair commented Dec 20, 2019

This script only works up to and including Nexus Repository Manager 3.19.

In 3.20 and beyond, take a look at the changes needed here:

https://gist.github.com/nblair/85b34948de59e5a5f458fb81fb014d00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment