jenkins the definitive guide

(Jeff_L) #1

There are two Jenkins plugins that can help you do this. The Audit Trail plugin keeps a record of user
changes in a special log file. And the JobConfigHistory plugin lets you keep a copy of previous versions
of the various system and job configuration files that Jenkins uses.


The Audit Trail Plugin keeps track of the main user actions in a set of rolling log files. To set this up,
go to the Plugin Manager page and select the Audit Trail plugin in the list of available plugins. Then,
as usual, click on Install and restart Jenkins once the plugin has been downloaded.


You can set up the audit trail configuration in the Audit Trail section of the main Jenkins configuration
page (see Figure 7.28, “Configuring the Audit Trail plugin”). The most important field is the Log
Location, which is where you indicate the directory in which the log files are to be written. The audit trail
is designed to produce system-style log files, which are often placed in a special system directory such
as /var/log. You can also configure the number of log files to be maintained, and the (approximate)
maximum size of each file. The simplest option is to provide an absolute path (such as /var/log/
hudson.log), in which case Jenkins will write to log files with names like /var/log/hudson.log.1,
/var/log/hudson.log.2, and so forth. Of course, you need to ensure that the user running your
Jenkins instance is allowed to write to this directory.


Figure 7.28. Configuring the Audit Trail plugin


You can also use the format defined in the Java logging FileHandler^1 class for more control over the
generated log files. In this format, you can insert variables such as %h, for the current user’s home
directory, and %t, for the system temporary directory, to build a more dynamic file path.


By default, the details recorded in the audit logs are fairly sparse—they effectively record key actions
performed, such as creating, modifying or deleting job configurations or views, and the user who
performed the actions. The log also shows how individual build jobs started. An extract of the default
log is shown here:


Dec 27, 2010 9:16:08 AM /job/game-of-life/configSubmit by johnsmart
Dec 27, 2010 9:16:42 AM /view/All/createItem by johnsmart
Dec 27, 2010 9:16:57 AM /job/game-of-life-prod-deployment/doDelete by johnsmart
Dec 27, 2010 9:24:38 AM job/game-of-life/ #177 Started by user johnsmart
Dec 27, 2010 9:25:57 AM job/game-of-life-acceptance-tests/ #107 Started by upstream
project "game-of-life" build number 177
Dec 27, 2010 9:25:58 AM job/game-of-life-functional-tests/ #7 Started by upstream

(^1) http://download.oracle.com/javase/1.5.0/docs/api/java/util/logging/FileHandler.html

Free download pdf