405 - HTTP method POST is not supported by this URL

Why do I receive a 405 Message. I don’t understand. Please help! What do I need to change in my configuration?

vi nexus.properties

. . .

Sonatype Nexus

==============

This is the most basic configuration of Nexus.

Jetty section

application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus

Nexus section

nexus-work=${bundleBasedir}/…/sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

orientdb buffer size in megabytes

storage.diskCache.bufferSize=4096

pa -ef | grep nexus | grep -v grep

nexus 18639 1 0 19:46 ? 00:00:00 /opt/nexus/nexus/bin/jsw/linux-x86-64/wrapper /opt/nexus/nexus/bin/jsw/conf/wrapper.conf wrapper.syslog.ident=nexus wrapper.pidfile=/opt/nexus/nexus/bin/jsw/linux-x86-64/nexus.pid wrapper.daemonize=TRUE

amazon-ebs: nexus    18641 18639  0 19:46 ?        00:00:00 java -Djava.io.tmpdir=./tmp -Djava.net.preferIPv4Stack=true -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl -Xms256m -Xmx768m -Djava.library.path=bin/jsw/lib -classpath bin/jsw/lib/wrapper-3.2.3.jar:./lib/logback-core-1.2.3.jar:./lib/metrics-jetty-2.2.0.jar:./lib/jetty-http-8.1.16.v20140903.jar:./lib/jetty-io-8.1.16.v20140903.jar:./lib/jul-to-slf4j-1.7.25.jar:./lib/javax.servlet-3.0.0.v201112011016.jar:./lib/nexus-bootstrap-2.14.15-01.jar:./lib/jetty-util-8.1.16.v20140903.jar:./lib/jetty-security-8.1.16.v20140903.jar:./lib/jetty-jmx-8.1.16.v20140903.jar:./lib/jetty-client-8.1.16.v20140903.jar:./lib/plexus-interpolation-1.16.jar:./lib/jetty-deploy-8.1.16.v20140903.jar:./lib/slf4j-api-1.7.25.jar:./lib/jetty-rewrite-8.1.16.v20140903.jar:./lib/jetty-webapp-8.1.16.v20140903.jar:./lib/jetty-xml-8.1.16.v20140903.jar:./lib/metrics-logback-2.2.0.jar:./lib/jetty-continuation-8.1.16.v20140903.jar:./lib/jetty-server-8.1.16.v20140903.jar:./lib/logback-access-1.2.3.jar:./lib/metrics-core-2.2.0.jar:./lib/logback-classic-1.2.3.jar:./lib/jetty-servlet-8.1.16.v20140903.jar:./conf/ -Dwrapper.key=TbPvsi2NLYmi5sCA -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=18639 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.sonatype.nexus.bootstrap.jsw.JswLauncher ./conf/jetty.xml ./conf/jetty-requestlog.xml

vi repository.json

{

"name": "docker-repository",

"type": "groovy",

"content": "import org.sonatype.nexus.blobstore.api.BlobStoreManager; import org.sonatype.nexus.repository.storage.WritePolicy; repository.createDockerHosted('demodkr', 5000, 443, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, true, true, WritePolicy.ALLOW)"

}

setup.sh
. . .
chown nexus:nexus /tmp/repository.json
chown nexus:nexus /tmp/maven.json
chown nexus:nexus /tmp/version.json
echo "################################################################################################### "
echo " "
echo " "
echo “Upload Groovy Script”
su nexus
export NEXUS_USERNAME=“admin”
export NEXUS_PASSWORD=“admin123”

nexus_default_context_path = ndcp

#export ndcp=“siesta/rest/v1/script/”
export ndcp=""
curl -XPOST -u $NEXUS_USERNAME:$NEXUS_PASSWORD --header “Content-Type: application/json” ‘http://localhost:8081/nexus/${ndcp}’ -d @/tmp/repository.json
echo " "
echo " "
echo "################################################################################################### "
. . .

RESULT

amazon-ebs: ###################################################################################################
amazon-ebs:
amazon-ebs:
amazon-ebs: Upload Groovy Script

==> amazon-ebs: % Total % Received % Xferd Average Speed Time Time Time Current
==> amazon-ebs: Dload Upload Total Spent Left Speed
==> amazon-ebs: 100 1008 0 690 100 318 33064 15238 --:–:-- --:–:-- --:–:-- 34500
amazon-ebs:
amazon-ebs:
amazon-ebs: 405 - HTTP method POST is not supported by this URL
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:

405 - HTTP method POST is not supported by this URL


amazon-ebs:

HTTP method POST is not supported by this URL


amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs:
amazon-ebs: ###################################################################################################

The URL looks wrong, it should be /service/rest/v1/script, not /siesta/rest/v1/script:

https://help.sonatype.com/display/NXRM3/Script+API#ScriptAPI-AddScript

I agree if this was version 3 but I am using version 2.14

Nexus Repo 2.x does not have support for groovy scripting, and does not have support for docker repositories. You’ll need to upgrade to Nexus Repo 3 for this to work.

I upgraded to 3.0

What is the proper context and url?

[nexus@ip-10-1-0-104 root]$ grep context /app/nexus/nexus/etc/nexus-default.properties
nexus-context-path=/

[nexus@ip-10-1-0-104 root]$ export NEXUS_USERNAME=“admin”
[nexus@ip-10-1-0-104 root]$ export NEXUS_PASSWORD=$(cat /app/nexus/sonatype-work/nexus3/admin.password)
[nexus@ip-10-1-0-104 root]$ curl -XPOST -u $NEXUS_USERNAME:$NEXUS_PASSWORD --header “Content-Type: application/json” ‘http://localhost:8081/${ndcp}’ -d @/tmp/repository.json

405 - Nexus Repository Manager

. . .

Nexus Repository Manager
OSS 3.19.1-01
. . . Error 405 Method Not Allowed
HTTP method POST is not supported by this URL