Reputation: 139
I find it hard to read the Jenkins javadoc. (I'll already here apologize for my java ignorance. I just have basic knowledge and are only able to write simple programs.)
When working in Jenkins and groovy I found the below useful example that shows how to find all Jenkins jobs and print some property from it:
def hi = hudson.model.Hudson.instance
hi.getItems(hudson.model.Project).each {project ->
println(project.lastBuild.result)
}
It shows how to get the lastBuild.result
property of the project
object. Reading the API docs on hudson.model.Hudson
I find a method getItems
that returns some List
of an arbitrary Class
. So I assume that project
is of class hudson.model.Project
.
Now to my problem. When I read the documentation on hudson.model.Project
I can't find any lastBuild
property. The only properties that are listed are the inherited ones. No listing of the class' own properties.
Where do I find such a list? Or what is it that I don't understand?
Thanks!
Upvotes: 3
Views: 1692
Reputation: 1805
If I know a class name or field name in the Jenkins model for whatever I am dealing with, I often find it easier to go directly to the Jenkins source code on GitHub to understand it. So you could go to https://github.com/jenkinsci/jenkins and search for lastBuild there. If you are running Groovy script in Jenkins and you want to know what class some object x is, just do "println x. getClass(). getName()". Then you can find more about the class searching the GitHub repo. Of course you could pull down all the Jenkins source code locally and navigate and search through it with something like IntelliJ IDEA or another Java IDE. You need to be comfortable with reading Java code.
Upvotes: 2