I have a requirement to Activate and Deactivate "Deployment Policy" through REST API. So basically speaking, from command line how will i switch the "Deployment Policy" to "Allow Redeploy" and "Disable Redeploy". Is there any way.
Thanks, sstar
Assuming you have Nexus running on http://localhost:8081/nexus
which is the default for a local install, which you would use for local development..
You can access the repo setup for the 'snapshots' with
curl http://localhost:8081/nexus/service/local/repositories/snapshots
which would result in something like
<repository>
<data>
<contentResourceURI>http://localhost:8081/nexus/content/repositories/snapshots</contentResourceURI>
<id>snapshots</id>
<name>Snapshots</name>
<provider>maven2</provider>
<providerRole>org.sonatype.nexus.proxy.repository.Repository</providerRole>
<format>maven2</format>
<repoType>hosted</repoType>
<exposed>true</exposed>
<writePolicy>ALLOW_WRITE</writePolicy>
<browseable>true</browseable>
<indexable>true</indexable>
<notFoundCacheTTL>1440</notFoundCacheTTL>
<repoPolicy>SNAPSHOT</repoPolicy>
<downloadRemoteIndexes>false</downloadRemoteIndexes>
<defaultLocalStorageUrl>file:/opt/tools/sonatype-work/nexus/storage/snapshots/</defaultLocalStorageUrl>
</data>
</repository>
Notice the "writePolicy" value ALLOW_WRITE. It is equivalent to "allow redeploy' in the user interface. ALLOW_WRITE_ONCE is equivalent to "disallow redeploy".
If you look at the REST API docs on your local install at http://localhost:8081/nexus/nexus-restlet1x-plugin/default/docs/index.html
you can see that you can also do a PUT request for a specific repo. So you would get the setup, update the write policy value and then put it back.
Depending on what you use to implement the REST call this will look differently. Check out the book chapter for more info on all that.