11label = " ${ UUID.randomUUID().toString()} "
22BUILD_FOLDER = " /go"
33expired= 240
4- quay_user = " iguazio"
5- quay_credentials = " iguazio-prod-quay-credentials"
6- docker_user = " iguaziodocker"
7- docker_credentials = " iguazio-prod-docker-credentials"
8- artifactory_user = " k8s"
9- artifactory_url = " iguazio-prod-artifactory-url"
10- artifactory_credentials = " iguazio-prod-artifactory-credentials"
114git_project = " prometheus"
125git_project_user = " v3io"
13- git_deploy_user = " iguazio-prod-git-user"
146git_deploy_user_token = " iguazio-prod-git-user-token"
7+ git_deploy_user_private_key = " iguazio-prod-git-user-private-key"
158
16- properties([pipelineTriggers([[$class : ' PeriodicFolderTrigger' , interval : ' 2m' ]])])
179podTemplate(label : " ${ git_project} -${ label} " , yaml : """
1810apiVersion: v1
1911kind: Pod
@@ -57,34 +49,21 @@ spec:
5749) {
5850 node(" ${ git_project} -${ label} " ) {
5951 withCredentials([
60- usernamePassword(credentialsId : git_deploy_user, passwordVariable : ' GIT_PASSWORD' , usernameVariable : ' GIT_USERNAME' ),
61- string(credentialsId : git_deploy_user_token, variable : ' GIT_TOKEN' ),
62- string(credentialsId : artifactory_url, variable : ' ARTIFACTORY_URL' )
52+ string(credentialsId : git_deploy_user_token, variable : ' GIT_TOKEN' )
6353 ]) {
64- def AUTO_TAG
6554 def TAG_VERSION
6655 def V3IO_TSDB_VERSION
56+ pipelinex = library(identifier : ' pipelinex@DEVOPS-204-pipelinex' , retriever : modernSCM(
57+ [$class : ' GitSCMSource' ,
58+ credentialsId : git_deploy_user_private_key,
59+ remote : " git@github.com:iguazio/pipelinex.git" ])). com. iguazio. pipelinex
60+ multi_credentials= [pipelinex.DockerRepo . ARTIFACTORY_IGUAZIO , pipelinex.DockerRepo . DOCKER_HUB , pipelinex.DockerRepo . QUAY_IO ]
6761
6862 stage(' get tag data' ) {
6963 container(' jnlp' ) {
70- TAG_VERSION = sh(
71- script : " echo ${ TAG_NAME} | tr -d '\\ n' | egrep '^v[\\ .0-9]*.*-v[\\ .0-9]*\$ ' | sed 's/v//'" ,
72- returnStdout : true
73- ). trim()
64+ TAG_VERSION = github. get_tag_version(TAG_NAME , ' ^v[\\ .0-9]*.*-v[\\ .0-9]*\$ ' )
65+ PUBLISHED_BEFORE = github. get_tag_published_before(git_project, git_project_user, " v${ TAG_VERSION} " , GIT_TOKEN )
7466
75- sh " curl -v -H \" Authorization: token ${ GIT_TOKEN} \" https://api.github.com/repos/${ git_project_user} /${ git_project} /releases/tags/v${ TAG_VERSION} > ~/tag_version"
76-
77- AUTO_TAG = sh(
78- script : " cat ~/tag_version | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[\" body\" ]'" ,
79- returnStdout : true
80- ). trim()
81-
82- PUBLISHED_BEFORE = sh(
83- script : " tag_published_at=\$ (cat ~/tag_version | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[\" published_at\" ]'); SECONDS=\$ (expr \$ (date +%s) - \$ (date -d \"\$ tag_published_at\" +%s)); expr \$ SECONDS / 60 + 1" ,
84- returnStdout : true
85- ). trim(). toInteger()
86-
87- echo " $AUTO_TAG "
8867 echo " $TAG_VERSION "
8968 echo " $PUBLISHED_BEFORE "
9069 }
@@ -98,64 +77,43 @@ spec:
9877 returnStdout : true
9978 ). trim()
10079
101- sh """
102- cd ${ BUILD_FOLDER}
103- git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ git_project_user} /${ git_project} .git src/github.com/${ git_project} /${ git_project}
104- cd ${ BUILD_FOLDER} /src/github.com/${ git_project} /${ git_project}
105- rm -rf vendor/github.com/v3io/v3io-tsdb/
106- git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ git_project_user} /v3io-tsdb.git vendor/github.com/v3io/v3io-tsdb
107- cd vendor/github.com/v3io/v3io-tsdb
108- git checkout "v${ V3IO_TSDB_VERSION} "
109- rm -rf .git vendor/github.com/${ git_project}
110- """
111- }
112- }
113-
114- stage(' build prometheus in dood' ) {
115- container(' docker-cmd' ) {
116- sh """
117- cd ${ BUILD_FOLDER} /src/github.com/${ git_project} /${ git_project}
118- docker build . -f Dockerfile.multi --tag ${ docker_user} /v3io-prom:${ TAG_VERSION} --tag ${ docker_user} /v3io-prom:latest --tag quay.io/${ quay_user} /v3io-prom:${ TAG_VERSION} --tag quay.io/${ quay_user} /v3io-prom:latest --tag ${ ARTIFACTORY_URL} /${ artifactory_user} /v3io-prom:${ TAG_VERSION} --tag ${ ARTIFACTORY_URL} /${ artifactory_user} /v3io-prom:latest
119- """
120- }
121- }
80+ dir(" ${ BUILD_FOLDER} /src/github.com/${ git_project} /${ git_project} " ) {
81+ git(changelog : false , credentialsId : git_deploy_user_private_key, poll : false , url : " git@github.com:${ git_project_user} /${ git_project} .git" )
82+ sh(" git checkout v${ TAG_VERSION} " )
83+ sh(" rm -rf vendor/github.com/v3io/v3io-tsdb/" )
84+ }
12285
123- stage(' push to hub' ) {
124- container(' docker-cmd' ) {
125- withDockerRegistry([credentialsId : docker_credentials, url : " https://index.docker.io/v1/" ]) {
126- sh " docker push docker.io/${ docker_user} /v3io-prom:${ TAG_VERSION} "
127- sh " docker push docker.io/${ docker_user} /v3io-prom:latest"
86+ dir(" ${ BUILD_FOLDER} /src/github.com/${ git_project} /${ git_project} /vendor/github.com/v3io/v3io-tsdb" ) {
87+ git(changelog : false , credentialsId : git_deploy_user_private_key, poll : false , url : " git@github.com:${ git_project_user} /v3io-tsdb.git" )
88+ sh(" git checkout v${ V3IO_TSDB_VERSION} " )
89+ sh(" rm -rf vendor/github.com/${ git_project} " )
12890 }
12991 }
13092 }
13193
132- stage(' push to quay ' ) {
94+ stage(" build ${ git_project } in dood " ) {
13395 container(' docker-cmd' ) {
134- withDockerRegistry([credentialsId : quay_credentials, url : " https://quay.io/api/v1/" ]) {
135- sh " docker push quay.io/${ quay_user} /v3io-prom:${ TAG_VERSION} "
136- sh " docker push quay.io/${ quay_user} /v3io-prom:latest"
96+ dir(" ${ BUILD_FOLDER} /src/github.com/${ git_project} /${ git_project} " ) {
97+ sh(" docker build . -f Dockerfile.multi --tag v3io-prom:${ TAG_VERSION} " )
13798 }
13899 }
139100 }
140101
141- stage(' push to artifactory ' ) {
102+ stage(' push' ) {
142103 container(' docker-cmd' ) {
143- withDockerRegistry([credentialsId : artifactory_credentials, url : " https://${ ARTIFACTORY_URL} /api/v1/" ]) {
144- sh " docker push ${ ARTIFACTORY_URL} /${ artifactory_user} /v3io-prom:${ TAG_VERSION} "
145- sh " docker push ${ ARTIFACTORY_URL} /${ artifactory_user} /v3io-prom:latest"
146- }
104+ dockerx. images_push_multi_registries([" v3io-prom:${ TAG_VERSION} " ], multi_credentials)
147105 }
148106 }
149107
150108 stage(' update release status' ) {
151- 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}'"
109+ container(' jnlp' ) {
110+ github. update_release_status(git_project, git_project_user, " v${ TAG_VERSION} " , GIT_TOKEN )
111+ }
152112 }
153113 } else {
154114 stage(' warning' ) {
155115 if (PUBLISHED_BEFORE >= expired) {
156116 echo " Tag too old, published before $PUBLISHED_BEFORE minutes."
157- } else if (AUTO_TAG . startsWith(" Autorelease" )) {
158- echo " Autorelease does not trigger this job."
159117 } else {
160118 echo " ${ TAG_VERSION} is not release tag."
161119 }
0 commit comments