GithubHelp home page GithubHelp logo

alexistimic / nexus-scripting-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sonatype-nexus-community/nexus-scripting-examples

0.0 1.0 0.0 44 KB

Sample scripts that use NXRM's scripting interface

HTML 90.62% JavaScript 0.24% CSS 3.77% Groovy 4.61% Shell 0.76%

nexus-scripting-examples's Introduction

Integration API Scripting Examples

Example projects for the Integration API as documented in https://help.sonatype.com/display/NXRM3/REST+and+Integration+API

See what other interesting scripts have been created at https://community.sonatype.com

Getting Started

Look at the examples in these projects to get more familiar with how to load, run, and write your own scripts to run inside of Nexus Repository Manager.

Step 1 - simple-shell-example

simple JSON script files and shell scripts for interaction with the REST API

Step 2 - nexus-script-example

Maven project for script development with IntelliJ IDEA-supported code completion

Step 3 - complex-script

complex provisioning setup based on a shell script invoking numerous groovy scripts for upload and execution

Passing Parameters

When running the script, the body of the POST request will be passed to your groovy in the args field. You can treat this as a normal string, use Groovy’s JsonSlurper to parse it as JSON, or read in any other groovy way.

The echo.json sample shows this in action. To test it out:

  1. First, cut and paste the contents of echo.json into the body field in the Nexus API UI for adding a new script and give your script a name, and click the "execute" button to submit the POST /v1/script request to save the script in your instance of Nexus Repository Manager

  2. Next, using the name from Step 1, execute the POST /v1/script/{name}/run request with any text you choose in the body.

  3. Notice that the response for Step 2 will return the text that you passed in!

For a more interesting example, see addRole.groovy and the corresponding documentation at the bottom of https://help.sonatype.com/repomanager3/rest-and-integration-api/script-api/examples. This script allows you to create your own custom REST API that enables you automate the creation of new Roles inside of Nexus Repository Manager.

API Reference

There are 4 officially supported API interfaces:

  1. Core

  2. BlobStore

  3. Repository

  4. Security

To learn more about the methods in each interface, use code complete in your favorite IDE with the nexus-script-example project, or take a look at the Javadoc index.html

nexus-scripting-examples's People

Contributors

ataylor284 avatar peterlynch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.