forked from v3io/tsdb-nuclio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
129 lines (120 loc) · 4.98 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
label = "${UUID.randomUUID().toString()}"
BUILD_FOLDER = "/go"
expired=240
git_project = "tsdb-nuclio"
git_project_user = "v3io"
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}", yaml: """
apiVersion: v1
kind: Pod
metadata:
name: "${git_project}-${label}"
labels:
jenkins/kube-default: "true"
app: "jenkins"
component: "agent"
spec:
shareProcessNamespace: true
containers:
- name: jnlp
image: jenkins/jnlp-slave
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 1
memory: 2Gi
volumeMounts:
- name: go-shared
mountPath: /go
- name: docker-cmd
image: docker
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
volumeMounts:
- name: docker-sock
mountPath: /var/run
- name: go-shared
mountPath: /go
volumes:
- name: docker-sock
hostPath:
path: /var/run
- name: go-shared
emptyDir: {}
"""
) {
node("${git_project}-${label}") {
withCredentials([
string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN')
]) {
def TAG_VERSION
def DOCKER_TAG_VERSION
pipelinex = library(identifier: 'pipelinex@DEVOPS-204-pipelinex', retriever: modernSCM(
[$class: 'GitSCMSource',
credentialsId: git_deploy_user_private_key,
remote: "[email protected]:iguazio/pipelinex.git"])).com.iguazio.pipelinex
multi_credentials=[pipelinex.DockerRepo.ARTIFACTORY_IGUAZIO, pipelinex.DockerRepo.DOCKER_HUB, pipelinex.DockerRepo.QUAY_IO]
common.notify_slack {
stage('get tag data') {
container('jnlp') {
TAG_VERSION = github.get_tag_version(TAG_NAME)
DOCKER_TAG_VERSION = github.get_docker_tag_version(TAG_NAME)
PUBLISHED_BEFORE = github.get_tag_published_before(git_project, git_project_user, "${TAG_VERSION}", GIT_TOKEN)
echo "$TAG_VERSION"
echo "$PUBLISHED_BEFORE"
}
}
if (TAG_VERSION != null && TAG_VERSION.length() > 0 && PUBLISHED_BEFORE < expired) {
stage('prepare sources') {
container('jnlp') {
dir("${BUILD_FOLDER}/src/github.com/v3io/${git_project}") {
git(changelog: false, credentialsId: git_deploy_user_private_key, poll: false, url: "[email protected]:${git_project_user}/${git_project}.git")
sh("git checkout ${TAG_VERSION}")
}
}
}
parallel(
'build tsdb-ingest': {
container('docker-cmd') {
dir("${BUILD_FOLDER}/src/github.com/v3io/${git_project}/functions/ingest") {
sh("docker build . --tag tsdb-ingest:${DOCKER_TAG_VERSION}")
}
}
container('docker-cmd') {
dockerx.images_push_multi_registries(["tsdb-ingest:${DOCKER_TAG_VERSION}"], multi_credentials)
}
},
'build tsdb-query': {
container('docker-cmd') {
dir("${BUILD_FOLDER}/src/github.com/v3io/${git_project}/functions/query") {
sh("docker build . --tag tsdb-query:${DOCKER_TAG_VERSION}")
}
}
container('docker-cmd') {
dockerx.images_push_multi_registries(["tsdb-query:${DOCKER_TAG_VERSION}"], multi_credentials)
}
}
)
stage('update release status') {
container('jnlp') {
github.update_release_status(git_project, git_project_user, "${TAG_VERSION}", GIT_TOKEN)
}
}
} else {
stage('warning') {
if (PUBLISHED_BEFORE >= expired) {
currentBuild.result = 'ABORTED'
error("Tag too old, published before $PUBLISHED_BEFORE minutes.")
} else {
currentBuild.result = 'ABORTED'
error("${TAG_VERSION} is not release tag.")
}
}
}
}
}
}
}