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') {
def workdir = 'dockerfiles/services/gitea'
pipeline {
agent { label 'docker' }
options {
buildDiscarder(logRotator(numToKeepStr: '2'))
}
triggers {
cron('@weekly')
}
stages {
stage('prepare') {
git credentialsId: 'f1f58215-c789-44a2-9b72-50e4425cb061', url: 'ssh://git@git.xai-corp.net:10022/xai-corp.net/provisioning.git'
steps {
checkout scm
sh 'ls'
}
}
stage('build') {
steps {
dir(workdir) {
sh "DOCKER_HOST=dkhost:2376 docker-compose -f docker-compose.yml pull"
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
docker service update gitea_app
../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