-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
87 lines (83 loc) · 3.36 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
pipeline {
agent any
stages {
stage('Build images and push them to Dockerhub') {
when {
anyOf { branch 'main'; branch 'production'; branch 'feature/*' }
}
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
# docker build -t webarchiv/seeder:develop -t webarchiv/seeder:latest -t webarchiv/seeder:$(git rev-parse --short HEAD) .
# docker push webarchiv/seeder:develop
# docker push webarchiv/seeder:$(git rev-parse --short HEAD)
'''
}
}
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
'''
}
}
stage('Docker Compose') {
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
# ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /home/ansible/pywb/run-test.sh
# Následující vymřelo na nenalezení dockercopose
# ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.21 sudo /opt/pywb/run-test.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://app.webarchiv.cz je v perfektním stavu a stvrzuji, že může jít do produkce na https://webarchiv.cz."
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
# docker push webarchiv/seeder:latest
# cd ci
# ansible-playbook -i prod --private-key ${SSH_CREDS} -u ${SSH_CREDS_USR} prepare-configuration.yml
# ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 sudo /opt/pywb/run-prod.sh
'''
}
}
}
}