Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

Commit e16a6ac

Browse files
authored
Merge pull request #11 from v3io/DEVOPS-203-jenkinsfile
DEVOPS-203 Jenkinsfile
2 parents 7a56999 + 8d0cd93 commit e16a6ac

File tree

1 file changed

+51
-10
lines changed

1 file changed

+51
-10
lines changed

Jenkinsfile

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
label = "${UUID.randomUUID().toString()}"
22
BUILD_FOLDER = "/go"
3+
expired=240
4+
quay_user = "iguazio"
5+
quay_credentials = "iguazio-prod-quay-credentials"
36
docker_user = "iguaziodocker"
47
docker_credentials = "iguazio-prod-docker-credentials"
8+
artifactory_user = "k8s"
9+
artifactory_url = "iguazio-prod-artifactory-url"
10+
artifactory_credentials = "iguazio-prod-artifactory-credentials"
511
git_project = "tsdb-nuclio"
612
git_project_user = "v3io"
713
git_deploy_user = "iguazio-prod-git-user"
@@ -52,7 +58,8 @@ spec:
5258
node("${git_project}-${label}") {
5359
withCredentials([
5460
usernamePassword(credentialsId: git_deploy_user, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME'),
55-
string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN')
61+
string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN'),
62+
string(credentialsId: artifactory_url, variable: 'ARTIFACTORY_URL')
5663
]) {
5764
def AUTO_TAG
5865
def TAG_VERSION
@@ -82,7 +89,7 @@ spec:
8289
}
8390
}
8491

85-
if ( TAG_VERSION != null && TAG_VERSION.length() > 0 && PUBLISHED_BEFORE < 240 ) {
92+
if ( TAG_VERSION != null && TAG_VERSION.length() > 0 && PUBLISHED_BEFORE < expired ) {
8693
stage('prepare sources') {
8794
container('jnlp') {
8895
sh """
@@ -92,29 +99,63 @@ spec:
9299
}
93100
}
94101

95-
stage('build in dood') {
102+
stage('build tsdb-ingest in dood') {
96103
container('docker-cmd') {
97104
sh """
98105
cd ${BUILD_FOLDER}/src/github.com/v3io/${git_project}/functions/ingest
99-
docker build . --tag tsdb-ingest:latest --tag ${docker_user}/tsdb-ingest:${TAG_VERSION}
106+
docker build . --tag tsdb-ingest:${TAG_VERSION} --tag ${docker_user}/tsdb-ingest:${TAG_VERSION} --tag ${docker_user}/tsdb-ingest:latest --tag quay.io/${quay_user}/tsdb-ingest:${TAG_VERSION} --tag quay.io/${quay_user}/tsdb-ingest:latest --tag ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-ingest:${TAG_VERSION} --tag ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-ingest:latest
107+
"""
108+
}
109+
}
100110

111+
stage('build tsdb-query in dood') {
112+
container('docker-cmd') {
113+
sh """
101114
cd ${BUILD_FOLDER}/src/github.com/v3io/${git_project}/functions/query
102-
docker build . --tag tsdb-query:latest --tag ${docker_user}/tsdb-query:${TAG_VERSION}
115+
docker build . --tag tsdb-query:${TAG_VERSION} --tag ${docker_user}/tsdb-query:${TAG_VERSION} --tag ${docker_user}/tsdb-query:latest --tag quay.io/${quay_user}/tsdb-query:${TAG_VERSION} --tag quay.io/${quay_user}/tsdb-query:latest --tag ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-query:${TAG_VERSION} --tag ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-query:latest
103116
"""
104117
}
105118
}
106119

107120
stage('push to hub') {
108121
container('docker-cmd') {
109-
withDockerRegistry([credentialsId: docker_credentials, url: ""]) {
110-
sh "docker push ${docker_user}/tsdb-ingest:${TAG_VERSION}"
111-
sh "docker push ${docker_user}/tsdb-query:${TAG_VERSION}"
122+
withDockerRegistry([credentialsId: docker_credentials, url: "https://index.docker.io/v1/"]) {
123+
sh "docker push docker.io/${docker_user}/tsdb-ingest:${TAG_VERSION};"
124+
sh "docker push docker.io/${docker_user}/tsdb-ingest:latest;"
125+
sh "docker push docker.io/${docker_user}/tsdb-query:${TAG_VERSION};"
126+
sh "docker push docker.io/${docker_user}/tsdb-query:latest;"
112127
}
113128
}
114129
}
130+
131+
stage('push to quay') {
132+
container('docker-cmd') {
133+
withDockerRegistry([credentialsId: quay_credentials, url: "https://quay.io/api/v1/"]) {
134+
sh "docker push quay.io/${quay_user}/tsdb-ingest:${TAG_VERSION}"
135+
sh "docker push quay.io/${quay_user}/tsdb-ingest:latest"
136+
sh "docker push quay.io/${quay_user}/tsdb-query:${TAG_VERSION}"
137+
sh "docker push quay.io/${quay_user}/tsdb-query:latest"
138+
}
139+
}
140+
}
141+
142+
stage('push to artifactory') {
143+
container('docker-cmd') {
144+
withDockerRegistry([credentialsId: artifactory_credentials, url: "https://${ARTIFACTORY_URL}/api/v1/"]) {
145+
sh "docker push ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-ingest:${TAG_VERSION}"
146+
sh "docker push ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-ingest:latest"
147+
sh "docker push ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-query:${TAG_VERSION}"
148+
sh "docker push ${ARTIFACTORY_URL}/${artifactory_user}/tsdb-query:latest"
149+
}
150+
}
151+
}
152+
153+
stage('update release status') {
154+
sh "release_id=\$(curl -H \"Content-Type: application/json\" -H \"Authorization: token ${GIT_TOKEN}\" -X GET https://api.github.com/repos/${git_project_user}/${git_project}/releases/tags/v${TAG_VERSION} | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[\"id\"]'); curl -v -H \"Content-Type: application/json\" -H \"Authorization: token ${GIT_TOKEN}\" -X PATCH https://api.github.com/repos/${git_project_user}/${git_project}/releases/\${release_id} -d '{\"prerelease\": false}'"
155+
}
115156
} else {
116157
stage('warning') {
117-
if (PUBLISHED_BEFORE >= 240) {
158+
if (PUBLISHED_BEFORE >= expired) {
118159
echo "Tag too old, published before $PUBLISHED_BEFORE minutes."
119160
} else if (AUTO_TAG.startsWith("Autorelease")) {
120161
echo "Autorelease does not trigger this job."
@@ -125,4 +166,4 @@ spec:
125166
}
126167
}
127168
}
128-
}
169+
}

0 commit comments

Comments
 (0)