make gitea/Jenkinsfile declarative

This commit is contained in:
2019-02-10 10:43:38 -05:00
parent c5818a7266
commit 464e6db82f
2 changed files with 46 additions and 23 deletions

View File

@@ -1,30 +1,47 @@
node('docker') { pipeline {
def workdir = 'dockerfiles/services/gitea' agent { label 'docker' }
options {
stage('prepare') { buildDiscarder(logRotator(numToKeepStr: '2'))
git credentialsId: 'f1f58215-c789-44a2-9b72-50e4425cb061', url: 'ssh://git@git.xai-corp.net:10022/xai-corp.net/provisioning.git'
sh 'ls'
} }
triggers {
stage('build') { cron('@weekly')
dir(workdir) {
sh "DOCKER_HOST=dkhost:2376 docker-compose -f docker-compose.yml pull"
}
} }
stages {
stage('deploy') { stage('prepare') {
dir(workdir) { steps {
sh """ checkout scm
docker stack deploy --with-registry-auth --prune -c docker-compose.yml gitea sh 'ls'
docker service update gitea_app }
"""
} }
}
stage('smoke tests') { stage('build') {
dir(workdir) { steps {
sleep 60 dir(workdir) {
sh "curl -If http://dkhost:10080" sh "DOCKER_HOST=${docker_host} docker-compose -f docker-compose.yml pull"
}
}
} }
stage('deploy') {
steps {
dir(workdir) {
sh """
export DOCKER_HOST=${docker_host}
docker stack deploy --with-registry-auth --prune -c docker-compose.yml gitea
../scaleout.sh gitea_app 180
"""
}
}
}
stage('smoke tests') {
steps {
dir(workdir) {
sleep 60
sh "curl -If http://dkhost:10080"
}
}
}
} }
} }

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
REPLICA_COUNT=`docker service inspect $1 | jq '.[0].Spec.Mode.Replicated.Replicas'`
./timeout.sh -t $2 docker service scale $1=$(($REPLICA_COUNT*2))
./timeout.sh -t $2 docker service scale $1=$(($REPLICA_COUNT))
docker service update -q $1