Last active
May 18, 2018 14:15
-
-
Save LenarBad/a583cd3bf05129b4ad9df0e37a21c5cb to your computer and use it in GitHub Desktop.
Jenkins dynamic Extended Choice Parameter with service call (Groovy Script)
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
// host will be passed in the groovy bindings for extended choice plugin. | |
def getVersion = { host, path -> | |
try { | |
def version = new groovy.json.JsonSlurper().parse(new URL("https://${host}${path}")).version | |
return version | |
} catch(Exception e) { | |
return null | |
} | |
} | |
String version = getVersion(host, "/version") | |
if(version == null) { | |
version = getVersion(host, "/info") | |
} | |
return version ?: 'RELEASE' |
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
def version = new groovy.json.JsonSlurper().parse(new URL("https://test.xxxx.com/info")).version | |
return [version] | |
// also set Default value if this failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment