@@ -5,66 +5,71 @@ def github_user = "gkirok"
55def docker_user = " gallziguazio"
66
77
8+ properties([pipelineTriggers([[$class : ' PeriodicFolderTrigger' , interval : ' 2m' ]])])
9+ stage(' release' ) {
10+ def TAG_VERSION = sh(
11+ script : " echo ${ TAG_NAME} | tr -d '\n ' | egrep '^v[\\ .0-9]*-v[\\ .0-9]*\$ '" ,
12+ returnStdout : true
13+ ). trim()
14+ if ( TAG_VERSION ) {
15+ podTemplate(label : " prometheus-${ label} " , inheritFrom : ' kube-slave-dood' ) {
16+ node(" prometheus-${ label} " ) {
17+ withCredentials([
18+ usernamePassword(credentialsId : ' 4318b7db-a1af-4775-b871-5a35d3e75c21' , passwordVariable : ' GIT_PASSWORD' , usernameVariable : ' GIT_USERNAME' ),
19+ secretText(credentialsId : ' dd7f75c5-f055-4eb3-9365-e7d04e644211' , secretText : ' GIT_TOKEN' )
20+ ]) {
21+ stage(' get release' ) {
22+ // sh "curl https://api.github.com/repos/gkirok/prometheus/releases/latest"
23+ sh """
24+ curl -H "Authorization: bearer ${ GIT_TOKEN} " -X POST -d '{"query": "query { repository(owner:\" gkirok\" , name:\" prometheus\" ) { releases(last: 5) { nodes { tag { name } } } } }"' https://api.github.com/graphql
25+ """
26+ }
827
9- podTemplate(label : " prometheus-${ label} " , inheritFrom : ' kube-slave-dood' ) {
10- node(" prometheus-${ label} " ) {
11- withCredentials([
12- usernamePassword(credentialsId : ' 4318b7db-a1af-4775-b871-5a35d3e75c21' , passwordVariable : ' GIT_PASSWORD' , usernameVariable : ' GIT_USERNAME' ),
13- ]) {
14- stage(' get release' ) {
15- // sh "curl https://api.github.com/repos/gkirok/prometheus/releases/latest"
16- sh """
17- curl -X POST -d " \\
18- { \\
19- \\ "query\\ ": \\ "query { viewer { login }}\\ " \\
20- } \\
21- " https://api.github.com/graphql
22- """
23- }
24-
25- stage(' prepare sources' ) {
26- sh """
27- cd ${ BUILD_FOLDER}
28- pwd
29- git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ github_user} /prometheus.git src/github.com/prometheus/prometheus
30- cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus
31- rm -rf vendor/github.com/v3io/v3io-tsdb/
32- git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ github_user} /v3io-tsdb.git vendor/github.com/v3io/v3io-tsdb
33- cd vendor/github.com/v3io/v3io-tsdb
34- git checkout ${ V3IO_TSDB_VERSION}
35- rm -rf .git vendor/github.com/prometheus
36- """
37- }
28+ stage(' prepare sources' ) {
29+ sh """
30+ cd ${ BUILD_FOLDER}
31+ pwd
32+ git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ github_user} /prometheus.git src/github.com/prometheus/prometheus
33+ cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus
34+ rm -rf vendor/github.com/v3io/v3io-tsdb/
35+ git clone https://${ GIT_USERNAME} :${ GIT_PASSWORD} @github.com/${ github_user} /v3io-tsdb.git vendor/github.com/v3io/v3io-tsdb
36+ cd vendor/github.com/v3io/v3io-tsdb
37+ git checkout ${ V3IO_TSDB_VERSION}
38+ rm -rf .git vendor/github.com/prometheus
39+ """
40+ }
3841
39- def V3IO_PROM_VERSION = sh (
40- script : " cat ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus/VERSION" ,
41- returnStdout : true
42- ). trim()
42+ def V3IO_PROM_VERSION = sh(
43+ script : " cat ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus/VERSION" ,
44+ returnStdout : true
45+ ). trim()
4346
44- stage(' build in dood' ) {
45- container(' docker-cmd' ) {
46- sh """
47- cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus
48- docker build . -t ${ docker_user} /v3io-prom:${ V3IO_PROM_VERSION} -${ V3IO_TSDB_VERSION} -f Dockerfile.multi
49- """
50- withDockerRegistry([ credentialsId : " 472293cc-61bc-4e9f-aecb-1d8a73827fae" , url : " " ]) {
51- sh " docker push ${ docker_user} /v3io-prom:${ V3IO_PROM_VERSION} -${ V3IO_TSDB_VERSION} "
47+ stage(' build in dood' ) {
48+ container(' docker-cmd' ) {
49+ sh """
50+ cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus
51+ docker build . -t ${ docker_user} /v3io-prom:${ V3IO_PROM_VERSION} -${ V3IO_TSDB_VERSION} -f Dockerfile.multi
52+ """
53+ withDockerRegistry([credentialsId : " 472293cc-61bc-4e9f-aecb-1d8a73827fae" , url : " " ]) {
54+ sh " docker push ${ docker_user} /v3io-prom:${ V3IO_PROM_VERSION} -${ V3IO_TSDB_VERSION} "
55+ }
56+ }
5257 }
53- }
54- }
5558
56- stage(' git push' ) {
57- try {
58- sh """
59- git config --global user.email '${ GIT_USERNAME} @iguazio.com'
60- git config --global user.name '${ GIT_USERNAME} '
61- cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus;
62- git add vendor/github.com/v3io/v3io-tsdb;
63- git commit -am 'Updated TSDB to ${ V3IO_TSDB_VERSION} ';
64- git push origin master
65- """
66- } catch (err) {
67- echo " Can not push code to git"
59+ stage(' git push' ) {
60+ try {
61+ sh """
62+ git config --global user.email '${ GIT_USERNAME} @iguazio.com'
63+ git config --global user.name '${ GIT_USERNAME} '
64+ cd ${ BUILD_FOLDER} /src/github.com/prometheus/prometheus;
65+ git add vendor/github.com/v3io/v3io-tsdb;
66+ git commit -am 'Updated TSDB to ${ V3IO_TSDB_VERSION} ';
67+ git push origin master
68+ """
69+ } catch (err) {
70+ echo " Can not push code to git"
71+ }
72+ }
6873 }
6974 }
7075 }
0 commit comments