Created
July 16, 2018 16:50
-
-
Save Malinskiy/a1bdb266e02212c2b51c8ac62adc4453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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