Jenkins' start up is based on the same idea as the modern Unix init mechanism like initng/upstart/SMF. It first builds a set of tasks that are units of the initialization work, and have them declare dependencies among themselves. For example, jobs are only loaded after all the plugins are initialized, and restoring the build queue requires all the jobs to be loaded.
Such micro-scopic dependencies are organized into a bigger directed acyclic graph, which is then executed in a reactor. During execution of the reactor, additional tasks can be discovred and added to the DAG. We use this additional indirection to:
- Perform initialization in parallel where possible.
- Provide progress report on where we are in the initialization.
- Collect status of the initialization and their failures.
To create a bit of structure on this task DAG, Jenkins defines a series of milestones, that each signifies a key step during the initialization phase (again, this is akin to the runlevel in Unix.)
These milestones can be useful when you are adding your own tasks to the initialization.
Participating to the initialization
From your plugin or from somewhere in the core, you can have your code executed during the initialization by annotating it with @Initializer