Created
October 6, 2015 17:26
-
-
Save cg-soft/4251ad83932340129925 to your computer and use it in GitHub Desktop.
Discover Groovy Properties and Methods
This file contains hidden or 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
// 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