-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
118 lines (110 loc) · 3.81 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
pipeline {
agent {
node {
label 'pipeline'
}
}
options {
timeout(time: 20, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '25'))
}
environment {
TIMESTAMP = "$BUILD_TIMESTAMP"
}
stages {
stage('Test and Debug Info') {
steps {
sh """
echo 'Test and Setup'
echo 'Show running user'
whoami
echo 'Show Java version'
java --version
echo 'Show Docker version'
docker --version
echo 'Show PWD'
pwd
echo 'Show dir contents'
ls -la
"""
}
}
stage('Remove Existing Sphinx Containers') {
steps {
sh """
sudo docker container stop sphinx || true
sudo docker container rm sphinx || true
# the 'true' makes this pass every time
# So if the container isn't present and these commands fail it doesn't break the build
"""
}
}
stage('Sphinx Doc Setup') {
steps {
sh """
ls -la
sudo rm /docs/* -R || true #true - won't fail if non-existent
sudo mkdir /docs || true
sudo chmod 777 /docs
sudo chmod 777 /var/ip.txt
set -a
. /var/ip.txt
set +a
sudo sed -i 's','pipelineIP',"\$pipelineIP",'g' capstone/what_happend.jinja
sudo sed -i 's','jenkinsIP',"\$jenkinsIP",'g' capstone/what_happend.jinja
sudo cp ./* /docs/ -R
ls -la /docs/
"""
}
}
stage('Build Sphinx Artifacts') {
steps {
sh """
sudo docker run --rm -v /docs:/docs --name sphinx localhost:5000/sphinx-latexpdf:4.5.0 make html
sudo docker run --rm -v /docs:/docs --name sphinx localhost:5000/sphinx-latexpdf:4.5.0 make latexpdf
sudo cp /docs/_build/latex/simplilearncaltechdevopscapstoneproject.pdf /docs/_build/html/simplilearncaltechdevopscapstoneproject.pdf
"""
}
}
stage('Reload Apache') {
steps {
sh """
sudo docker container restart sphinx-html
"""
}
}
stage('Run Automated Tests') {
steps {
sh """
sudo python3 automated_testing.py
"""
}
}
stage('PROD: Sphinx Doc Setup') {
steps {
sh """
ls -la
sudo rm /PROD-docs/* -R || true #true - won't fail if non-existent
sudo mkdir /PROD-docs || true
sudo chmod 777 /PROD-docs
sudo cp /docs/* /PROD-docs/ -R
ls -la /PROD-docs/
"""
}
}
stage('PROD: Reload Apache') {
steps {
sh """
sudo docker container restart prod-sphinx-html
"""
}
}
}
//I'm not sure how this will play with existing terraform deployed objects. Like it may make Terraform deploy new ones each time since it doesn't save the state
// post {
// always {
// echo 'Cleaning Up Workspace'
// deleteDir() /* clean up our workspace */
// }
// }
}