forked from istio/old_mixer_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
134 lines (124 loc) · 3.91 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
#!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)
}
// PR from master to stable branch for qualification
if (utils.runStage('STABLE_PRESUBMIT')) {
stablePresubmit(gitUtils, bazel, utils)
}
// Postsubmit form stable branch, post qualification
if (utils.runStage('STABLE_POSTSUBMIT')) {
stablePostsubmit(gitUtils, bazel, utils)
}
}
def presubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/mixer') {
bazel.updateBazelRc()
stage('Bazel Build') {
bazel.fetch('-k //...')
bazel.build('//...')
}
stage('Bazel Tests') {
bazel.test('//...')
}
stage('Code Check') {
sh('bin/linters.sh')
sh('bin/racetest.sh')
}
stage('Code Coverage') {
sh('bin/codecov.sh > codecov.report')
sh('bazel-bin/bin/toolbox/presubmit/package_coverage_check')
utils.publishCodeCoverage('MIXER_CODECOV_TOKEN')
}
stage('Docker Test Push') {
def images = 'mixer'
def tags = env.GIT_SHA
// Docker images built with bazel
utils.publishDockerImagesToContainerRegistry(images, tags)
// Docker images built with docker
sh("bin/publish-docker-images.sh -t ${tags} -h gcr.io/istio-testing")
}
}
}
def postsubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/mixer') {
bazel.updateBazelRc()
stage('Code Coverage') {
bazel.fetch('-k //...')
bazel.build('//...')
sh('bin/bazel_to_go.py')
bazel.test('//...')
sh('bin/codecov.sh')
utils.publishCodeCoverage('MIXER_CODECOV_TOKEN')
}
utils.fastForwardStable('mixer')
}
}
def stablePresubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/mixer') {
bazel.updateBazelRc()
stage('Docker Push') {
def images = 'mixer'
def tags = env.GIT_SHA
// Docker images built with bazel
utils.publishDockerImagesToContainerRegistry(images, tags)
// Docker images built with docker
sh("bin/publish-docker-images.sh -t ${tags} -h gcr.io/istio-testing")
}
}
}
def stablePostsubmit(gitUtils, bazel, utils) {
goBuildNode(gitUtils, 'istio.io/mixer') {
bazel.updateBazelRc()
stage('Docker Push') {
def images = 'mixer,mixer_debug'
def tags = "${env.GIT_SHORT_SHA},${env.ISTIO_VERSION}-${env.GIT_SHORT_SHA}"
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}"
}
}
// Docker images built with bazel
utils.publishDockerImagesToDockerHub(images, tags)
utils.publishDockerImagesToContainerRegistry(images, tags, '', 'gcr.io/istio-io')
// Docker images built with docker
sh("bin/publish-docker-images.sh -t ${tags} -h gcr.io/istio-io")
withDockerRegistry([credentialsId: env.ISTIO_TESTING_DOCKERHUB]) {
sh("bin/publish-docker-images.sh -t ${tags} -h docker.io/istio")
}
}
}
}