forked from v3io/prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
115 lines (108 loc) · 4.26 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
label = "${UUID.randomUUID().toString()}"
BUILD_FOLDER = "/go"
expired=240
git_project = "prometheus"
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 V3IO_TSDB_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, '^v[\\.0-9]*.*-v[\\.0-9]*\$')
DOCKER_TAG_VERSION = github.get_docker_tag_version(TAG_NAME, '^v[\\.0-9]*.*-v[\\.0-9]*\$')
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/${git_project}/${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}")
}
}
}
stage("build ${git_project} in dood") {
container('docker-cmd') {
dir("${BUILD_FOLDER}/src/github.com/${git_project}/${git_project}") {
sh("docker build . -f Dockerfile.multi --tag v3io-prom:${DOCKER_TAG_VERSION}")
}
}
}
stage('push') {
container('docker-cmd') {
dockerx.images_push_multi_registries(["v3io-prom:${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) {
echo "Tag too old, published before $PUBLISHED_BEFORE minutes."
} else {
echo "${TAG_VERSION} is not release tag."
}
}
}
}
}
}
}