In several places inside Jenkins, a series of "hook scripts" get executed to allow some actions to take place in reaction to some key events.
These scripts are written in Groovy, and get executed inside the same JVM as Jenkins, allowing full access to the domain model of Jenkins. For given hook HOOK, the following locations are searched:
WEB-INF/HOOK.groovy
injenkins.war
WEB-INF/HOOK.groovy.d/*.groovy
in the lexical order injenkins.war
$JENKINS_HOME/HOOK.groovy
$JENKINS_HOME/HOOK.groovy.d/*.groovy
in the lexical order
HOOK.groovy.d
is suitable to avoid conflicts — multiple entities can insert stuff into the hook without worrying about overwriting each other's code.
The following events use this mechanism:
- init: Configuring Jenkins upon start up / Post-initialization script
- boot-failure: Boot failure hook