Splunk for Jenkins
To Install Develop Version
- clone the repo
$ mvn package
- That will generate
splunk-devops/target/splunk-devops.hpi
which you can install into Jenkins by the web interface or just put it in theJENKINS_HOME/plugins
folder. $ mvn clean verify -Dhost=localhost -Dusername=admin -Dpassword=changeme
to run tests against local splunk instance
To Setup
Configure plugin
-
Enter Hostname, Port, and Token
-
Enable RawEvent support if you are using Splunk version 6.3.1511 or later
-
Click "Test Connection" to verify the config
-
Enable it and Save
Customize Job Data Sent to Splunk
Customize post job processing
- In the advance configure section, you can customize the post data using groovy DSL
send(Object message)
will send the information to splunkAbstractBuild build
,Map env
can be used directly. Variable env is a Map of Environment variables, build is hudson.model.AbstractBuildgetBuildEvent()
will return metadata about the build, such as build result, build URL, user who triggered the buildgetJunitReport(int pageSize)
will return a list of test results, which contains total, passes, failures, skips, time and testcase of type List<hudson.tasks.junit.CaseResult>getJunitReport()
is an alias ofgetJunitReport(Integer.MAX_VALUE)[0]
- sendCoverageReport(pageSize) send coverage report, with pagination support
- sendTestReport(pageSize) send Test report, with pagination support
archive(String includes, String excludes, boolean uploadFromSlave, String fileSizeLimit)
send log file to splunkarchive(String includes)
is an alias ofarchive(includes, null, false, "")
getAction(Class type)
is an alias ofbuild.getAction(type)
getActionByClassName(String className)
same asgetAction(Class type)
but no need to import the class before usehasPublisherName(String className)
check whether the publisher is configured for the build (applied to AbstractBuild only)- Here is the default settings for post job data processing
//send job metadata and junit reports with page size set to 50 (each event contains max 50 test cases)
splunkins.sendTestReport(50)
//send coverage, each event contains max 50 class metrics
splunkins.sendCoverageReport(50)
//send all logs from workspace to splunk, with each file size limits to 10MB
splunkins.archive("**/*.log", null, false, "10MB")
Customize log files at job level
-
Add a "post-build action" called "Send data to Splunk"
-
Enter an ant-style pattern matching string for your junit xml collection
Dashboard
you can get the "Splunk App for Jenkins" App from splunk base
System Requirement
You need enable "HTTP Event Collector" In Splunk to use the plugin, please checkout HTTP Event Collector