This repository was archived by the owner on Jan 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
60 lines (50 loc) · 1.49 KB
/
Copy pathJenkinsfile
File metadata and controls
60 lines (50 loc) · 1.49 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def publish_to_influxdb() {
// version >= 2.0
def influxdb = Jenkins.instance.getDescriptorByType(jenkinsci.plugins.influxdb.InfluxDbStep.DescriptorImpl)
// Create target
def target = new jenkinsci.plugins.influxdb.models.Target()
// Set target details
// Mandatory fields
target.description = 'Post-Build Target'
target.url = 'http://192.168.49.248:8086'
target.username = 'cip-user'
// version < 2.0
target.password = hudson.util.Secret.fromString('6y9JhiktEMzxd7')
// version >= 2.0
//target.password = hudson.util.Secret.fromString('my-password')
target.database = 'influxdb_plugin'
// Add a target by using the created target object
influxdb.addTarget(target)
influxdb.save()
// Write stuff to InfluxDB
influxDbPublisher(selectedTarget: 'Post-Build Target')
// Remove a target by using the target description field value
influxdb.removeTarget('Post-Build Target')
influxdb.save()
}
pipeline{
agent any
stages{
stage('Init'){
steps{
echo "Testing . "
}
}
stage('Build'){
steps{
echo 'Building Project . . '
}
}
stage('Deploy'){
steps{
echo 'code deployed'
}
}
}
post
{
always {
publish_to_influxdb()
}
}
}