-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (48 loc) · 2.03 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pipeline {
agent any
stages {
stage('Deploy to test') {
when {
anyOf { branch 'main'; branch 'production'; branch 'feature/*' }
}
environment {
SSH_CREDS = credentials('ansible')
}
steps {
sh '''#!/usr/bin/env bash
# Make Bash Great Again
set -o errexit # exit when a command fails.
set -o nounset # exit when using undeclared variables
set -o pipefail # catch non-zero exit code in pipes
# set -o xtrace # uncomment for bug hunting
cd ci
ansible-playbook -i test --private-key ${SSH_CREDS} -u ${SSH_CREDS_USR} deploy.yaml
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /home/traefik/run.sh
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /home/pywb-test/run.sh
'''
}
}
stage('Deploy to production & run pywb') {
when {
anyOf { branch 'production'}
}
environment {
SSH_CREDS = credentials('ansible')
}
steps {
input "Přísáhám před krutým a přísným bohem, že https://test.pywb.webarchiv.cz/wayback je v perfektním stavu a stvrzuji, že může jít do produkce na https://pywb.webarchiv.cz/wayback."
sh '''#!/usr/bin/env bash
# Make Bash Great Again
set -o errexit # exit when a command fails.
set -o nounset # exit when using undeclared variables
set -o pipefail # catch non-zero exit code in pipes
# set -o xtrace # uncomment for bug hunting
cd ci
ansible-playbook -i prod --private-key ${SSH_CREDS} -u ${SSH_CREDS_USR} deploy.yaml
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /home/traefik/run.sh
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /home/pywb-prod/run.sh
'''
}
}
}
}