Adding script to Nexus OSS

Absolutely. The following gist contains a few examples of single and multiline groovy scripts and a bash script which can upload them via the REST API.

The pertinent part is line L33 in the bash script

"content": "$(sed '/^$/d; /^\/\//d; s/"/\\"/g' ${script} | tr '\n' ';')",

which is taking the multiline script and performing the following transformations:

  • Removes empty lines
  • Removes line comments
  • Escapes double quotes \\"
  • Replaces newlines with semicolons