I'm trying to write a Groovy script that will query our Sonatype Nexus OSS Maven repository for information about a given artifact (war file) that was just deployed as part of a build. I then want to set Jenkins job parameters so I can use them in subsequent steps in the job.
My script is currently using the groovyx.net.http.RESTClient and works in stand-alone mode see script below, but when I run it as a Groovy System Script it throws the following:
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1')import groovyx.net.http.RESTClient
query : ['r': 'myrepo', 'g': 'mygroupid', 'a': 'myartifactid', 'v': '1.0-SNAPSHOT', 'e': 'jar'],
headers: ['Accept': 'application/json', "Content-Type": 'application/json']
def json = resp.getData()
def version = json.data.version
def url = json.data.repositoryPath
def sha1 = json.data.sha1
printf( "Found: version: '%s' url: '%s' sha1: '%s'", version, url, sha1)