forked from v3io/frames
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
214 lines (211 loc) · 13.6 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
label = "${UUID.randomUUID().toString()}"
git_project = "frames"
git_project_user = "v3io"
git_project_upstream_user = "v3io"
git_deploy_user = "iguazio-prod-git-user"
git_deploy_user_token = "iguazio-prod-git-user-token"
git_deploy_user_private_key = "iguazio-prod-git-user-private-key"
podTemplate(label: "${git_project}-${label}", inheritFrom: "jnlp-docker-golang-python37") {
node("${git_project}-${label}") {
pipelinex = library(identifier: 'pipelinex@development', retriever: modernSCM(
[$class : 'GitSCMSource',
credentialsId: git_deploy_user_private_key,
remote : "[email protected]:iguazio/pipelinex.git"])).com.iguazio.pipelinex
common.notify_slack {
withCredentials([
string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN'),
string(credentialsId: 'frames-ci-url', variable: 'FRAMES_CI_URL'),
usernamePassword(credentialsId: 'frames-ci-user-credentials', passwordVariable: 'FRAMES_CI_PASSWORD', usernameVariable: 'FRAMES_CI_USERNAME'),
]) {
github.branch(git_deploy_user, git_project, git_project_user, git_project_upstream_user, true, GIT_TOKEN) {
parallel(
'test-py': {
container('python37') {
stage('test-py') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("pip install pipenv")
common.shellc("make python-deps")
sh "make test-py"
}
}
}
},
'test-go': {
container('golang') {
stage('test-go') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
session = '{"url":"' + FRAMES_CI_URL + '","user":"' + FRAMES_CI_USERNAME + '","password":"' + FRAMES_CI_PASSWORD + '","container":"bigdata"}'
common.shellc("V3IO_SESSION='${session}' make test-go")
}
}
}
},
'make lint': {
container('golang') {
stage('make lint') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
sh "make lint"
}
}
}
}
)
}
github.pr(git_deploy_user, git_project, git_project_user, git_project_upstream_user, true, GIT_TOKEN) {
parallel(
'test-py': {
container('python37') {
stage('test-py') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("pip install pipenv")
common.shellc("make python-deps")
sh "make test-py"
}
}
}
},
'test-go': {
container('golang') {
stage('test-go') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
session = '{"url":"' + FRAMES_CI_URL + '","user":"' + FRAMES_CI_USERNAME + '","password":"' + FRAMES_CI_PASSWORD + '","container":"bigdata"}'
common.shellc("V3IO_SESSION='${session}' make test-go")
}
}
}
},
'make lint': {
container('golang') {
stage('make lint') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
sh "make lint"
}
}
}
}
)
}
github.release(git_deploy_user, git_project, git_project_user, git_project_upstream_user, true, GIT_TOKEN) {
RELEASE_ID = github.get_release_id(git_project, git_project_user, "${github.TAG_VERSION}", GIT_TOKEN)
parallel(
'build linux binaries': {
container('golang') {
stage('build linux binaries') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("FRAMES_TAG=${github.TAG_VERSION} GOARCH=amd64 GOOS=linux make frames-bin")
}
}
}
},
'build darwin binaries': {
container('golang') {
stage('build darwin binaries') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("FRAMES_TAG=${github.TAG_VERSION} GOARCH=amd64 GOOS=darwin make frames-bin")
}
}
}
},
'build windows binaries': {
container('golang') {
stage('build windows binaries') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("FRAMES_TAG=${github.TAG_VERSION} GOARCH=amd64 GOOS=windows make frames-bin")
}
}
}
},
'build frames': {
container('docker-cmd') {
stage('build frames') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("FRAMES_REPOSITORY= FRAMES_TAG=${github.DOCKER_TAG_VERSION} make build")
}
}
}
},
'build framulate': {
container('docker-cmd') {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
common.shellc("FRAMES_REPOSITORY= FRAMES_TAG=${github.DOCKER_TAG_VERSION} make build-framulate")
}
}
},
)
parallel(
'upload linux binaries': {
container('jnlp') {
stage('upload linux binaries') {
github.upload_asset(git_project, git_project_user, "framesd-${github.TAG_VERSION}-linux-amd64", RELEASE_ID, GIT_TOKEN, "${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}")
}
}
},
'upload linux binaries artifactory': {
container('jnlp') {
stage('upload linux binaries artifactory') {
withCredentials([
string(credentialsId: pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[2], variable: 'PACKAGES_ARTIFACTORY_PASSWORD')
]) {
common.upload_file_to_artifactory(pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[0], pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[1], PACKAGES_ARTIFACTORY_PASSWORD, "iguazio-devops/k8s", "framesd-${github.TAG_VERSION}-linux-amd64", "${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}")
}
}
}
},
'upload darwin binaries': {
container('jnlp') {
stage('upload darwin binaries') {
github.upload_asset(git_project, git_project_user, "framesd-${github.TAG_VERSION}-darwin-amd64", RELEASE_ID, GIT_TOKEN, "${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}")
}
}
},
'upload windows binaries': {
container('jnlp') {
stage('upload windows binaries') {
github.upload_asset(git_project, git_project_user, "framesd-${github.TAG_VERSION}-windows-amd64", RELEASE_ID, GIT_TOKEN, "${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}")
}
}
},
'upload to pypi': {
container('python37') {
stage('upload to pypi') {
release_body = github.get_release_body("frames", git_project_user, github.TAG_VERSION, GIT_TOKEN)
if (release_body.startsWith("Autorelease")) {
echo "Autorelease is not uploading frames py to pypi."
} else if( "${github.TAG_VERSION}" != "unstable" ) {
withCredentials([
usernamePassword(credentialsId: "iguazio-prod-pypi-credentials", passwordVariable: 'V3IO_PYPI_PASSWORD', usernameVariable: 'V3IO_PYPI_USER')
]) {
dir("${github.BUILD_FOLDER}/src/github.com/${git_project_upstream_user}/${git_project}") {
FRAMES_PYPI_VERSION = sh(
script: "echo ${github.DOCKER_TAG_VERSION} | awk -F - '{print \$1}'",
returnStdout: true
).trim()
common.shellc("pip install pipenv")
common.shellc("make python-deps")
sh "make test-py"
try {
common.shellc("TRAVIS_REPO_SLUG=v3io/frames V3IO_PYPI_USER=${V3IO_PYPI_USER} V3IO_PYPI_PASSWORD=${V3IO_PYPI_PASSWORD} TRAVIS_TAG=${FRAMES_PYPI_VERSION} make pypi")
} catch (err) {
unstable("Failed uploading to pypi")
// Do not continue stages
throw err
}
}
}
} else {
echo "Uploading to pypi only stable version"
}
}
}
},
)
container('docker-cmd') {
dockerx.images_push_multi_registries(
["frames:${github.DOCKER_TAG_VERSION}", "framulate:${github.DOCKER_TAG_VERSION}"],
[pipelinex.DockerRepo.ARTIFACTORY_IGUAZIO, pipelinex.DockerRepo.DOCKER_HUB, pipelinex.DockerRepo.QUAY_IO, pipelinex.DockerRepo.GCR_IO])
}
}
}
}
}
}