Skip to content

Instantly share code, notes, and snippets.

@Malinskiy
Created July 16, 2018 16:50
Show Gist options
  • Save Malinskiy/a1bdb266e02212c2b51c8ac62adc4453 to your computer and use it in GitHub Desktop.
Save Malinskiy/a1bdb266e02212c2b51c8ac62adc4453 to your computer and use it in GitHub Desktop.
nexusScriptsClient = new ResteasyClientBuilder().build() 
.register(new BasicAuthentication(nexusUsername, nexusPassword)) 
.target("$proxyInstanceHost/service/rest") 
.proxy(ScriptClient)  
void uploadAndRunScript(String remoteConfig) { 
// Look to see if a script with this name already exists so we can update if necessary
 
boolean newScript = true 
try { 
nexusScriptsClient.read(remoteScriptName) 
newScript = false 
println "Existing Script named '$remoteScriptName' will be updated" 
catch (NotFoundException e) { 
println "Script named '$remoteScriptName' will be created" 
}   // upload script
 
def script = new ScriptXO(remoteScriptName, remoteScriptFile.text, 'groovy') 
if (newScript) { 
nexusScriptsClient.add(script) 
} else { 
nexusScriptsClient.edit(remoteScriptName, script) 
println "Script uploaded. Running…"   // run script
 
nexusScriptsClient.run(remoteScriptName, remoteConfig) 
println "Seems good." 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment