Skip to content

Instantly share code, notes, and snippets.

@cg-soft
Created October 6, 2015 17:26
Show Gist options
  • Save cg-soft/4251ad83932340129925 to your computer and use it in GitHub Desktop.
Save cg-soft/4251ad83932340129925 to your computer and use it in GitHub Desktop.
Discover Groovy Properties and Methods
// These two functions prove invaluable to understand and explore
// the jenkins data model. Include in a system groovy script or in
// the script console, and discover where the data really sits.
// See also http://stackoverflow.com/questions/32876496/how-can-i-retrieve-the-build-parameters-from-a-queued-job
// Credit to http://stackoverflow.com/users/172599/dave-bacher
def showProps(inst, prefix="Properties:") {
println prefix
for (prop in inst.properties) {
def pc = ""
if (prop.value != null) {
pc = prop.value.class
}
println(" $prop.key : $prop.value ($pc)")
}
}
def showMethods(inst, prefix="Methods:") {
println prefix
inst.metaClass.methods.name.unique().each {
println " $it"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment