Plugin implements some interfaces and marks the implementation to use annotation @Extension so Jenkins can load it dynamically
package com.splunk.splunkjenkins
Follow jenkins conventions, using java bean property host, port, token, useSSL, scriptPath etc and some helper method such as
doCheckHost to validate host, doTestHttpInput to verify connection, see also https://wiki.jenkins-ci. org/display/JENKINS/Form+Validation
package com.splunk.splunkjenkins.listeners, receives notifications from jenkins, for example in Jenkins delete job action
/**
* Called in response to {@link Job#doDoDelete(StaplerRequest, StaplerResponse)}
*/
public void onDeleted(TopLevelItem item) throws IOException {
ItemListener.fireOnDeleted(item);
items.remove(item.getName());
// For compatibility with old views:
for (View v : views)
v.onJobRenamed(item, item.getName(), null);
}
it will call fireOnDeleted to notify all ItemListeners
record user login/logout and failedToLogIn events
when user made changes to jenkins config (either plugin config or job config), record the config xml. disabled by default until user add jenkins_config.monitoring=true into metadata config
similar to SaveableListener but for Job only, it has finer grained audit event. used to capture job created, renamed, copied and deleted
listen for onEnterWaiting, onLeaveWaiting, onEnterBlocked, onLeaveBlocked, onEnterBuildable, onLeavebBuildable, and onLeft. Record the job queueTime in each of the phase along with other jenkins metrics and reports to Splunk.
listen for onStarted and onCompleted, and extract upstream job, build cause, scm, job result, and invoke DSL if defined
record slave online, offline, temporarilyOffline, and launchFailure
Contribute to post build step, user can custom the logs to send to splunk in addition to what we have in Groovy DSL.
add link to home page
add link to management page
and link to other types, such as Build, Computer
we extends AsyncPeriodicWork to run tasks periodic to gather agent metrics
SplunkLogService launched two threads to drain the splunk event queue, used (Splunk HTTP Event Collector)[http://dev.splunk.com/view/event-collector/SP-CAAAE6M] to pump data into splunk, message format
{
"time": 1426279439,
"host": "localhost",
"source": "datasource",
"sourcetype": "txt",
"index": "main",
"event": { jenkins_event_json_here }
}