Jenkins Source Analysis

Source: Internet
Author: User

Stapler

Stapler is a Lib library that binds application objects and URLs together, making it easier to write Web applications. The core idea of stapler is to automatically bind URLs to application objects and create an intuitive URL hierarchy.

Shows how the Stapler works:



The application's code information is displayed on the left, and the hierarchy of URLs is shown on the right. Through the reflection mechanism, stapler can bind URLs to application objects. For example, the root object of the application corresponds to the root "/" of the URL. objects accessed through the Getproject ("stapler") method are assigned to the URL "/project/stapler". In this way, the Application object model is converted directly to the hierarchy of URLs, as shown in the purple arrows.

Jenkins's class object and URL bindings are implemented by stapler. The Hudson instance is bound to the URL "/" as the root object, and the remainder is bound according to the accessibility of the object. For example, Hudson has a getjob (String) method, so according to the description, you can know that the URL "/job/foo/" will be bound to the object returned by Hudson.getjob ("foo").

JellyJelly is a scripting and processing engine based on Java technology and XML. Jelly is characterized by a number of executable tags based on the JSTL (JSP standard tag Library, JSP standards tag libraries), Ant, Velocity, and many other tools. Jelly also supports JEXL (Java expressions language, Java expression Language), and Jexl is an extended version of the JSTL expression language.

The interface drawing of Jenkins is achieved through jelly. The jelly file is located under the Resources directory, as shown in


Home file Rendering file is located in lib/layout/layout.jelly, reference example below, L:yui reference the current directory yui.jelly for rendering, view yui.jelly content, you can know here is the code to reference Yui-js file:

Persistence ofJenkins uses files to store data (all data is stored in $jenkins_home). Some data, such as the console output, is stored as a text file, and some data is stored in the same way as the Java configuration file format; Most structural data, such as the configuration or build of a project, is persisted through XStream, as shown in actual 3. You can see that Jenkins records all the build records for a Job through XStream.




Plug - ins

The object model of Jenkins is extensible, and with the extensibility points provided by Jenkins, we can develop plugins to extend Jenkins's functionality. So far, Jenkins has supported more than 600 plugins that support features such as software configuration Management (SCM), software testing, notifications (Notification), reports, and more.

Jenkins loads each plug-in with a separate class loader to avoid conflicts between plugins. Plug-ins are involved in the system's activities just like any other class built into Jenkins. In addition, the plug-in can be persisted through XStream, can provide the view technology by the Jelly, can provide the static resources such as the picture, the plug-in all functions can join seamlessly to the Jenkins built-in function.

Jenkins Portal File

The entry for the Jenkins code is the Webappmain class shown, located under Hudson (package)


Class Webappmain implements the Servletcontextlistener interface. The main purpose of this interface is to monitor the life cycle of ServletContext objects. The Servletcontextevent event is triggered when the Servlet container starts or terminates the Web app, and the event is handled by Servletcontextlistener. In addition, the Servletcontextlistener interface defines two methods, contextinitialized and contextdestroyed. By means of the method name, we can see that one of the two methods is the start time call (contextinitialized), and one is the time of termination (contextdestroyed).

A Jenkins object is initialized by the Contextinitialized method in the class. When the Servlet container is initialized, the Jenkins object is created by the Webappmain inittread thread.

Jenkins Source Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.