@@ -5,9 +5,13 @@ library changelog: false, identifier: 'lib@hetzner', retriever: modernSCM([
55
66pipeline {
77 agent {
8- label ' docker '
8+ label params . CLOUD == ' Hetzner ' ? ' launcher-x64 ' : ' micro-amazon '
99 }
1010 parameters {
11+ choice(
12+ choices : [' Hetzner' ,' AWS' ],
13+ description : ' Cloud infra for build' ,
14+ name : ' CLOUD' )
1115 string(
1216 defaultValue : ' https://github.com/percona/percona-backup-mongodb.git' ,
1317 description : ' URL for percona-mongodb-backup repository' ,
@@ -22,50 +26,50 @@ pipeline {
2226 stages {
2327 stage(' Get release branches' ) {
2428 steps {
25- withCredentials([[$class : ' AmazonWebServicesCredentialsBinding' , accessKeyVariable : ' AWS_ACCESS_KEY_ID' , credentialsId : ' AWS_STASH' , secretKeyVariable : ' AWS_SECRET_ACCESS_KEY' ]]) {
26- sh """
27- EC=0
28- aws s3 ls s3://percona-jenkins-artifactory/percona-backup-mongodb/branch_commit_id.properties || EC=\$ ?
29+ script {
30+ String S3_STASH = (params. CLOUD == ' Hetzner' ) ? ' HTZ_STASH' : ' AWS_STASH'
31+ String S3_ENDPOINT = (params. CLOUD == ' Hetzner' ) ? ' --endpoint-url https://fsn1.your-objectstorage.com' : ' --endpoint-url https://s3.amazonaws.com'
32+ withCredentials([[$class : ' AmazonWebServicesCredentialsBinding' , accessKeyVariable : ' AWS_ACCESS_KEY_ID' , credentialsId : S3_STASH , secretKeyVariable : ' AWS_SECRET_ACCESS_KEY' ]]) {
33+ sh """
34+ EC=0
35+ AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws s3 ls s3://percona-jenkins-artifactory/percona-backup-mongodb/branch_commit_id.properties ${ S3_ENDPOINT} --cli-connect-timeout 60 --cli-read-timeout 120 || EC=\$ ?
2936
30- if [ \$ {EC} = 1 ]; then
31- LATEST_RELEASE_BRANCH=\$ (git -c 'versionsort.suffix=-' ls-remote --heads --sort='v:refname' ${ GIT_REPO} release\\ * | tail -1)
32- BRANCH_NAME=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d "/" -f 3)
33- COMMIT_ID=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d " " -f 1)
37+ if [ \$ {EC} = 1 ]; then
38+ LATEST_RELEASE_BRANCH=\$ (git -c 'versionsort.suffix=-' ls-remote --heads --sort='v:refname' ${ GIT_REPO} release\\ * | tail -1)
39+ BRANCH_NAME=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d "/" -f 3)
40+ COMMIT_ID=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d " " -f 1)
3441
35- echo "BRANCH_NAME=\$ {BRANCH_NAME}" > branch_commit_id.properties
36- echo "COMMIT_ID=\$ {COMMIT_ID}" >> branch_commit_id.properties
42+ echo "BRANCH_NAME=\$ {BRANCH_NAME}" > branch_commit_id.properties
43+ echo "COMMIT_ID=\$ {COMMIT_ID}" >> branch_commit_id.properties
3744
38- aws s3 cp branch_commit_id.properties s3://percona-jenkins-artifactory/percona-backup-mongodb/
39- echo "START_NEW_BUILD=NO" > startBuild
40- else
41- aws s3 cp s3://percona-jenkins-artifactory/percona-backup-mongodb/branch_commit_id.properties .
42- source branch_commit_id.properties
45+ AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws s3 cp branch_commit_id.properties s3://percona-jenkins-artifactory/percona-backup-mongodb/ ${ S3_ENDPOINT } --cli-connect-timeout 60 --cli-read-timeout 120
46+ echo "START_NEW_BUILD=NO" > startBuild
47+ else
48+ AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws s3 cp s3://percona-jenkins-artifactory/percona-backup-mongodb/branch_commit_id.properties . ${ S3_ENDPOINT } --cli-connect-timeout 60 --cli-read-timeout 120
49+ source branch_commit_id.properties
4350
44- LATEST_RELEASE_BRANCH=\$ (git -c 'versionsort.suffix=-' ls-remote --heads --sort='v:refname' ${ GIT_REPO} release\\ * | tail -1)
45- LATEST_BRANCH_NAME=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d "/" -f 3)
46- LATEST_COMMIT_ID=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d " " -f 1)
51+ LATEST_RELEASE_BRANCH=\$ (git -c 'versionsort.suffix=-' ls-remote --heads --sort='v:refname' ${ GIT_REPO} release\\ * | tail -1)
52+ LATEST_BRANCH_NAME=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d "/" -f 3)
53+ LATEST_COMMIT_ID=\$ (echo \$ {LATEST_RELEASE_BRANCH} | cut -d " " -f 1)
4754
48- if [ "x\$ {COMMIT_ID}" != "x\$ {LATEST_COMMIT_ID}" ] || [ "x\$ {BRANCH_NAME}" != "x\$ {LATEST_BRANCH_NAME}" ]; then
49- echo "START_NEW_BUILD=YES" > startBuild
50- else
51- echo "START_NEW_BUILD=NO" > startBuild
52- fi
55+ if [ "x\$ {COMMIT_ID}" != "x\$ {LATEST_COMMIT_ID}" ] || [ "x\$ {BRANCH_NAME}" != "x\$ {LATEST_BRANCH_NAME}" ]; then
56+ echo "START_NEW_BUILD=YES" > startBuild
57+ else
58+ echo "START_NEW_BUILD=NO" > startBuild
59+ fi
5360
54- echo "BRANCH_NAME=\$ {LATEST_BRANCH_NAME}" > branch_commit_id.properties
55- echo "COMMIT_ID=\$ {LATEST_COMMIT_ID}" >> branch_commit_id.properties
56- aws s3 cp branch_commit_id.properties s3://percona-jenkins-artifactory/percona-backup-mongodb/
57- fi
58- """
59- }
60- script {
61+ echo "BRANCH_NAME=\$ {LATEST_BRANCH_NAME}" > branch_commit_id.properties
62+ echo "COMMIT_ID=\$ {LATEST_COMMIT_ID}" >> branch_commit_id.properties
63+ AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws s3 cp branch_commit_id.properties s3://percona-jenkins-artifactory/percona-backup-mongodb/ ${ S3_ENDPOINT} --cli-connect-timeout 60 --cli-read-timeout 120
64+ fi
65+ """
66+ }
6167 START_NEW_BUILD = sh(returnStdout : true , script : " source startBuild; echo \$ {START_NEW_BUILD}" ). trim()
6268 BRANCH_NAME = sh(returnStdout : true , script : " source branch_commit_id.properties; echo \$ {BRANCH_NAME}" ). trim()
6369 COMMIT_ID = sh(returnStdout : true , script : " source branch_commit_id.properties; echo \$ {COMMIT_ID}" ). trim()
6470 VERSION = sh(returnStdout : true , script : " source branch_commit_id.properties; echo \$ {BRANCH_NAME} | sed s:release\\ -::" ). trim()
6571 }
66-
6772 }
68-
6973 }
7074 stage(' Build needed' ) {
7175 when {
@@ -78,7 +82,7 @@ pipeline {
7882 """
7983 }
8084 slackNotify(" #releases-ci" , " #00FF00" , " [${ JOB_NAME} ]: new changes for branch ${ BRANCH_NAME} [commit id: ${ COMMIT_ID} ] were detected, build will be started soon" )
81- build job : ' pbm-autobuild-RELEASE' , parameters : [string(name : ' GIT_BRANCH' , value : BRANCH_NAME ), string(name : ' VERSION' , value : VERSION ), string(name : ' COMPONENT' , value : ' testing' )]
85+ build job : ' hetzner- pbm-autobuild-RELEASE' , parameters : [string( name : ' CLOUD ' , value : CLOUD ), string(name : ' GIT_BRANCH' , value : BRANCH_NAME ), string(name : ' VERSION' , value : VERSION ), string(name : ' COMPONENT' , value : ' testing' )]
8286 build job : ' pbm-release-test-run' , propagate : false , wait : false , parameters : [string(name : ' PBM_BRANCH' , value : BRANCH_NAME ), string(name : ' PBM_VERSION' , value : VERSION )]
8387 }
8488 }
0 commit comments