Skip to main content

Managing and Running Scripts

Once you have completed the creation of your script, you need to publish it to the repository manager for execution. This is done by REST API invocations.

For Repository Manager version 3.8.x and onwards, the REST API endpoint is:


For Repository Manager versions pre 3.8.x, the REST API endpoint is:



The following examples given below are against NXRM version 3.8+ so please amend the endpoint accordingly if running any NXRM 3 version before that.

This endpoint accepts JSON-formatted payloads with your script as the content.

Example JSON formatted file maven.json with a simple repository creation script:

  "name": "maven",
  "type": "groovy",
  "content": "repository.createMavenHosted('private')"

The JSON file maven.json located in the current directory can be published to the repository manager with an HTTP POST like:

curl -v -X POST -u admin:admin123 --header "Content-Type: application/json" 'http://localhost:8081/service/rest/v1/script' -d @maven.json

A list of scripts stored on the repository manager can be accessed with:

curl -v -X GET -u admin:admin123 'http://localhost:8081/service/rest/v1/script'

The same call with a script name appended returns the actual script content.

A script can be executed by sending a POST to the run method of the specific script.

curl -v -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://localhost:8081/service/rest/v1/script/maven/run'

A successful execution should result in a HTTP/1.1 200 OK.

Scripts can be removed with a HTTP DELETE operation to the specific script:

curl -v -X DELETE -u admin:admin123 'http://localhost:8081/service/rest/v1/script/maven'


Scripts can receive run-time parameters via the REST API:

curl -v -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://localhost:8081/service/rest/v1/script/updateAnonymousAccess/run' -d 'false'

and receive them as arguments that have to be parsed by the script as desired:


Multiple parameters can be passed in via a JSON file in the POST request:



Then the command would be similar to the following:

curl -k -u user:pass -X POST --header 'Content-Type: text/plain' http://localhost:8081/service/rest/v1/script/rebuild-maven-metadata/run -d @params.json

And you can access the parameters in your script code:

def request = new JsonSlurper().parseText(args);
assert request.repoName: 'repoName parameter is required';
assert request.groupId: 'groupId parameter is required';
assert request.artifactId: 'artifactId parameter is required';

Interaction with the REST API for scripts can be done with any scripting language capable of HTTP calls as mentioned above. In the following section you can find some further detailed examples.