This repository has been archived by the owner on Jun 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Jenkinsfile
158 lines (146 loc) · 4.11 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!groovy
@Library('testutils@stable-41b0bf6')
import org.istio.testutils.Utilities
import org.istio.testutils.GitUtilities
import org.istio.testutils.Bazel
// Utilities shared amongst modules
def gitUtils = new GitUtilities()
def utils = new Utilities()
def bazel = new Bazel()
// This should be updated for a release branch.
ISTIO_VERSION_URL = 'https://raw.githubusercontent.com/istio/istio/master/istio.RELEASE'
def setVersions() {
def version = sh(returnStdout: true, script: "curl ${ISTIO_VERSION_URL}").trim()
if (!(version ==~ /[0-9]+\.[0-9]+\.[0-9]+/)) {
error('Could not parse version')
}
def v = version.tokenize('.')
env.ISTIO_VERSION = version
env.ISTIO_MINOR_VERSION = "${v[0]}.${v[1]}"
}
mainFlow(utils) {
node {
setVersions()
gitUtils.initialize()
bazel.setVars()
}
// PR on master branch
if (utils.runStage('PRESUBMIT')) {
presubmit(gitUtils, bazel, utils)
}
// Postsubmit from master branch
if (utils.runStage('POSTSUBMIT')) {
postsubmit(gitUtils, bazel, utils)
}
// Creating release artifacts
if (utils.runStage('RELEASE')) {
release(gitUtils, bazel)
}
// Regression test to run for modules managed depends on
if (utils.runStage('REGRESSION')) {
regression(gitUtils, bazel, utils)
}
}
def presubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/pilot') {
bazel.updateBazelRc()
utils.initTestingCluster()
sh('ln -s ~/.kube/config platform/kube/')
stage('Bazel Build') {
// Use Testing cluster
sh('bin/install-prereqs.sh')
bazel.fetch('-k //...')
bazel.build('//...')
}
stage('Build istioctl') {
def remotePath = gitUtils.artifactsPath('istioctl')
sh("bin/upload-istioctl -p ${remotePath}")
}
stage('Go Build') {
sh('bin/init.sh')
}
stage('Code Check') {
sh('bin/check.sh')
}
stage('Bazel Tests') {
bazel.test('//...')
}
stage('Code Coverage') {
sh('bin/codecov.sh | tee codecov.report')
sh('bin/toolbox/pkg_coverage.sh')
utils.publishCodeCoverage('PILOT_CODECOV_TOKEN')
}
stage('Integration Tests') {
timeout(15) {
sh("bin/e2e.sh -tag ${env.GIT_SHA}")
}
}
}
}
def postsubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/pilot') {
bazel.updateBazelRc()
utils.initTestingCluster()
sh('ln -s ~/.kube/config platform/kube/')
stage('Code Coverage') {
sh('bin/install-prereqs.sh')
bazel.test('//...')
sh('bin/init.sh')
sh('bin/codecov.sh | tee codecov.report')
sh('bin/toolbox/pkg_coverage.sh')
utils.publishCodeCoverage('PILOT_CODECOV_TOKEN')
}
stage('Build istioctl') {
def remotePath = gitUtils.artifactsPath('istioctl')
sh("bin/upload-istioctl -r -p ${remotePath}")
}
stage('Integration Tests') {
timeout(60) {
sh("bin/e2e.sh -count 10 -logs=false -tag ${env.GIT_SHA}")
}
}
}
}
def release(gitUtils, bazel) {
goBuildNode(gitUtils, 'istio.io/pilot') {
bazel.updateBazelRc()
sh('touch platform/kube/config')
stage('Build istioctl') {
def remotePath = gitUtils.artifactsPath('istioctl')
sh("bin/upload-istioctl -r -p ${remotePath}")
}
stage('Docker Push') {
def tags = "${env.GIT_SHORT_SHA},${env.ISTIO_VERSION}-${env.GIT_SHORT_SHA}"
def hubs = 'gcr.io/istio-io,docker.io/istio'
if (env.GIT_TAG != '') {
if (env.GIT_TAG == env.ISTIO_VERSION) {
// Retagging
tags = "${env.ISTIO_VERSION},${env.ISTIO_MINOR_VERSION}"
} else {
tags += ",${env.GIT_TAG}"
}
}
sh("bin/push-docker -tag ${tags} -hub ${hubs}")
}
}
}
def regression(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/pilot') {
bazel.updateBazelRc()
utils.initTestingCluster()
stage('Bazel Build') {
// Use Testing cluster
sh('ln -s ~/.kube/config platform/kube/')
bazel.fetch('-k //...')
bazel.build('//...')
}
stage('Bazel Tests') {
bazel.test('//...')
}
stage('Integration Tests') {
timeout(15) {
sh("bin/e2e.sh -tag ${env.GIT_SHA}")
}
}
}
}