-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
3000.plugin-splunk.groovy
30 lines (26 loc) · 1.2 KB
/
3000.plugin-splunk.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import jenkins.model.Jenkins;
import jenkins.model.*;
import com.splunk.splunkjenkins.*;
println "///////////////////////////////////////////////////////////////////////////"
println "Init Hook: Splunk plugin"
println "///////////////////////////////////////////////////////////////////////////"
def splunk_app_url = "https://splunk.corp.example.com/en-US/app/splunk_app_jenkins/"
def splunk_collector_hostname = "splunk-collector.corp.example.com"
def splunk_collector_token = "123456"
def splunk_collector_port = 8088
def splunk_index = "jenkins_index_name"
def jenkins_hostname = "jenkins.corp.example.com"
def splunkInstallation = SplunkJenkinsInstallation.get()
splunkInstallation.setEnabled(true)
splunkInstallation.setHost(splunk_collector_hostname)
splunkInstallation.setPort(splunk_collector_port)
splunkInstallation.setToken(splunk_collector_token)
splunkInstallation.setUseSSL(true)
splunkInstallation.setMetadataHost(jenkins_hostname)
splunkInstallation.setMetaDataConfig("""
console_log.index=${splunk_index}
build_event.index=${splunk_index}
""".stripIndent())
splunkInstallation.setMetadataSource('jenkins')
splunkInstallation.setSplunkAppUrl(splunk_app_url)
splunkInstallation.save()