forked from influxdata/influxdata-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
130 lines (115 loc) · 3.32 KB
/
Jenkinsfile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pipeline {
agent any
options { skipDefaultCheckout() }
environment {
DOCKER_MAINTAINER = credentials("INFLUXDATA_DOCKER_MAINTAINER")
}
stages {
stage('Setup project workspace') {
steps {
dir('influxdata-docker') {
checkout scm
}
}
}
stage('Build docker images') {
parallel {
stage('chronograf') {
steps {
dir('influxdata-docker') {
sh './circle-test.sh chronograf'
}
}
}
stage('influxdb') {
steps {
dir('influxdata-docker') {
sh './circle-test.sh influxdb'
}
}
}
stage('kapacitor') {
steps {
dir('influxdata-docker') {
sh './circle-test.sh kapacitor'
}
}
}
stage('telegraf') {
steps {
dir('influxdata-docker') {
sh './circle-test.sh telegraf'
}
}
}
}
}
stage('Update official images') {
steps {
dir('official-images') {
checkout(
scm: [
$class: 'GitSCM',
branches: [[name: '*/master' ]],
userRemoteConfigs: [[
credentialsId: 'jenkins-hercules-ssh',
url: '[email protected]:influxdata/official-images.git',
]],
],
poll: false,
)
// Reset master to the value at origin.
sh "git checkout master && git reset --hard origin/master"
}
dir('influxdata-docker') {
sh "docker build -t influxdata/dockerlib:build-${BUILD_NUMBER} dockerlib"
}
withDockerContainer(image: "influxdata/dockerlib:build-${BUILD_NUMBER}") {
sh "cd influxdata-docker; dockerlib update"
}
}
post {
always {
sh "docker rmi -f influxdata/dockerlib:build-${BUILD_NUMBER}"
}
}
}
stage('Push changes to GitHub') {
when {
expression {
return sh(returnStatus: true, script: 'cd official-images; git diff --quiet') != 0
}
}
steps {
dir('official-images') {
sshagent(credentials: ['jenkins-hercules-ssh']) {
sh """
git -c user.name="Jonathan A. Sternberg" -c user.email="[email protected]" commit -am "Update influxdata images"
git push origin master
"""
}
sh """
desired_remote_url=git://github.com/docker-library/official-images.git
if current_remote_url=\$(git remote get-url upstream 2> /dev/null); then
if [ "\$current_remote_url" != "\$desired_remote_url" ]; then
git remote set-url upstream "\$desired_remote_url"
fi
else
git remote add upstream "\$desired_remote_url"
fi
"""
sh "docker pull jsternberg/hub"
withEnv(["GITHUB_USER=${DOCKER_MAINTAINER_USR}", "GITHUB_TOKEN=${DOCKER_MAINTAINER_PSW}"]) {
withDockerContainer(image: "jsternberg/hub") {
sh """
if ! hub pr show; then
hub pull-request -m "Update influxdata images"
fi
"""
}
}
}
}
}
}
}