Create repo Docker via API

docker

#1

Hi, a trying create registry in Nexus 3.14 via API

I`m used script

{
“name”: “docker”,
“type”: “groovy”,
“content”: “import org.sonatype.nexus.repository.Repository; import org.sonatype.nexus.repository.storage.WritePolicy; blobStore.createFileBlobStore(‘dockerblob’, ‘dockerblob’); repository.createDockerHosted(‘docker-production’, 5000, 5001, ‘dockerblob’, true, true, WritePolicy.ALLOW_ONCE)”
}

and then next

curl -v -X POST -u admin:admin123 --header “Content-Type: application/json” ‘http://localhost:8081/service/rest/v1/script’ -d @docker.json

curl -X POST -u admin:admin123 --header “Content-Type: text/plain” ‘http://localhost:8081/service/rest/v1/script/docker/run

And my Output

{
“name”: “test-docker-new”,
“result”: “javax.script.ScriptException: javax.validation.ConstraintViolationException”
}

What is wrong?


#2

Do you see a stack trace in the nexus logs?


#3

I tried this locally and I see the following stack trace:

2019-01-10 08:51:51,155-0600 WARN  [qtp973849294-85] admin org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID 622e80e5-1ac9-4049-a04c-948db08af525) Unexpected exception: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('“' (code 8220 / 0x201c)): was expecting double-quote to start field name
 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 2, column: 4]
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('“' (code 8220 / 0x201c)): was expecting double-quote to start field name
 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 2, column: 4]

That’s because your json (at least on this post) has “smart quotes” probably added by using a program like MS Word or Text Edit. Replacing the smart quotes with normal quotes works just fine. (I was able to create and run the script.)

{
"name": "docker",
"type": "groovy",
"content": "import org.sonatype.nexus.repository.Repository; import org.sonatype.nexus.repository.storage.WritePolicy; blobStore.createFileBlobStore('dockerblob', 'dockerblob'); repository.createDockerHosted('docker-production', 5000, 5001, 'dockerblob', true, true, WritePolicy.ALLOW_ONCE)"
}

#4

Thank you for the answer, i see log and :face_with_hand_over_mouth:
“found duplicated key”
“conflict port”
I feeling stupid man ))
And (jackson.core.JsonParseException: Unexpected character (’“’ )) because you copy script from here, this other format.
Thank you