Jenkins插件开发(3)——Jenkins架构(Architecture)

官方文档参照:https://wiki.jenkins-ci.org/display/JENKINS/Architecture

Jenkins is primarily a set of Java classes that model the concepts of a build system in a straight-forward fashion (and if you are using Jenkins, you've seen most of those already). There are classes like ProjectBuild, that represents what the name says. The root of this object model is Hudson, and all the other model objects are reachable from here.

Then there are interfaces and classes that model code that performs a part of a build, such as SCM for accessing source code control system, Ant for performing an Ant-based build,Mailer for sending out e-mail notifications.

Stapler

Those Jenkins classes are bound to URLs by using Stapler. The singleton Hudson instance is bound to the "/" URL, and the rest of the objects are bound according to their reachability from this root object.

For example, there's the Hudson.getJob(String) method. So the URL /job/foo/ will be bound to the object returned by Hudson.getJob("foo") (which would be a Project object that corresponds to the "foo" project. See stapler documentation for more about how it binds Java object model to a URL hierarchy.

Jenkins model objects have multiple "views" that are used to render HTML pages about each object. Jenkins uses Jelly as the view technology (which is somewhat similar to JSP+JSTL.) Views are really like methods, and each of them work against a particular class. So the views are organized according to classes that they belong to, just like methods are organized according to classes that they belong to. Again, see the stapler project for more about how this works.

原文地址:https://www.cnblogs.com/zhangqingsh/p/3025963.html