Skip to end of metadata
Go to start of metadata

The API for scripts is capable of a number of different tasks. This section provides examples for script writing, publishing and executing them.

The simple-shell-example project in the scripting section of the example project includes a number of JSON file with simple scripts:


simplest script to create a hosted Maven repository


simple script to create a hosted and proxy repository as well as a repository group for npm usage


simple script to create a hosted and proxy repository as well as a repository group for bower usage


parameterized script to enable or disable anonymous access

Simple shell scripts are added to contain the curl invocations to manage scripts via the REST API:

Upload a specified JSON file

Delete a script specified by its name

List all deployed scripts

Run a script specified by its name

Run the anonymous script on the server with the parameter true or false

Update an existing script by specifying the name and the JSON file to use for the update

An example sequence of creating and running a script is:

./ maven.json
./ maven

Subsequently you could list all scripts and delete the maven script with:

./ maven

Since scripts are typically longer than a single line and creating them in a separate file in the IDE is recommended, using a helper script that formats a .groovy file into a JSON file and submits it to the repository manager can be a convenient approach.

The complex-script project in the scripting section of example project includes an example implementation using Groovy invoked from a shell script. All scripts in this folder can be published and executed via the file. This results in the download of all required dependencies and the upload and execution of the referenced script. Alternatively, you can provision the scripts individually:

groovy addUpdateScript.groovy -u "admin" -p "admin123" -n "raw" -f "rawRepositories.groovy" -h "http://localhost:8081"
curl -v -X POST -u admin:admin123 --header "Content-Type: text/plain" "http://localhost:8081/service/siesta/rest/v1/script/raw/run"

The following scripts are available:


for NPM and Bower repositories suitable for server-side and client JavaScript-based development


creates a new blob store and uses it for a hosted raw repository


disables anonymous access, creates a new administrator account, creates a new role with a simple expansion to anonymous user role and a user, creates a new role with publishing access to all repositories and a user


configures the base URL capability and a proxy server

Logging from your scripts into the repository manager logs is automatically available and performed with the usual calls:'User jane.doe created')

The result of the last script line is by default returned as a string. This can be a message as simple as Success! or more complex structured data.

For instance, you can easily return JSON using built-in Groovy classes like:

return groovy.json.JsonOutput.toJson([result: 'Success!'])

which looks like:

    "result": "Success!"

Passing parameters to the script can use JSON encoded arguments like:

  "id": "foo",
  "name": "bar",
  "description": "baz",
  "privilegeIds": ["nx-all"],
  "roleIds": ["nx-admin"]

 which in turn can be parsed using the JsonSlurper class in the script:

import groovy.json.JsonSlurper
//expects json string with appropriate content to be passed in
def role = new JsonSlurper().parseText(args)
security.addRole(,, role.description, role.privilegeIds, role.roleIds)

You can read more about how to work with XML and JSON with Groovy on and

  • No labels