-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
160 lines (137 loc) · 3.68 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
pipeline {
agent any
stages {
stage('Build') {
parallel {
stage('CheckoutCode') {
steps {
sh '''echo "Building the server code..."
mvn -version
mkdir -p target
touch "target/server.war"
'''
stash(name: 'server', includes: '**/*.war')
}
}
stage('BuildDevCode') {
steps {
sh '''echo "Building the client code..."
npm install --save react
mkdir -p dist
cat > dist/index.html <<EOF
hello! welcome to Jenkins pipeline for CICD
EOF
touch "dist/client.js"
'''
stash(name: 'client', includes: '**/dist/*')
}
}
}
}
stage('UnitTest') {
parallel {
stage('CheckOutUnitTestCode') {
steps {
sh '''echo "mvn test -Dbrowser=chrome"
'''
}
}
stage('RunUnitTests') {
steps {
sh 'echo "mvn test -Dbrowser=firefox"'
}
}
stage('PublishReport') {
steps {
sh 'echo "Report Published for Unit Test"'
}
}
}
}
stage('Smoke Testing') {
parallel {
stage('Check Smoke Test') {
steps {
unstash 'server'
unstash 'client'
sh '''echo "deploy to server ..."
'''
echo 'APP_DIR=C:\\usr\\local\\tomcat\\webapps rm -rf $APP_DIR/ROOT cp target/server.war $APP_DIR/server.war mkdir -p $APP_DIR/ROOT cp dist/* $APP_DIR/ROOT C:\\usr\\local\\tomcat\\webapps\\startup.sh'
sh 'echo ":Check out code from SVN for Testing "'
}
}
stage('Run Smoke Test') {
steps {
sh 'echo " Running smoke test code"'
sh 'echo "Publish reports :=="'
}
}
stage('PublishE2EReport') {
steps {
input(message: 'Is Testing Passed', ok: 'Go Ahead with Deployment', submitter: '[email protected]')
}
}
}
}
stage('Deploy To TST') {
steps {
echo 'APP_DIR=C:\\usr\\local\\tomcat\\webapps rm -rf $APP_DIR/ROOT cp target/server.war $APP_DIR/server.war mkdir -p $APP_DIR/ROOT cp dist/* $APP_DIR/ROOT C:\\usr\\local\\tomcat\\webapps\\startup.sh'
sh 'echo "Deployment to the TST Server is done"'
unstash 'server'
unstash 'client'
sh 'echo "Deployment is done to test Env"'
}
}
stage('Regression Test on TST') {
parallel {
stage('Checkout Regression Test Code') {
steps {
sh 'echo "Checkout code from SVN"'
}
}
stage('Run Regression Test') {
steps {
sh 'echo "Run Regression Code on TST"'
}
}
stage('PublishE2EReport') {
steps {
sh 'echo "Publish Report for E2E on TST"'
input(message: 'Is Regression OK in TST', ok: 'Go Ahead with Deployment to UAT')
}
}
}
}
stage('Deploy UAT') {
steps {
unstash 'server'
unstash 'client'
}
}
stage('Regression Test on UAT') {
parallel {
stage('Checkout Regression Test Code') {
steps {
sh 'echo "Starting regression testing on UAT, Check out code from SVN for UAT"'
}
}
stage('Run Regression Test') {
steps {
sh 'echo "Running regression code"'
}
}
stage('Publish Report') {
steps {
sh 'echo "Publish Regression Report"'
input(message: 'Is regression OK', ok: 'Go Ahead to deploy in Prod', submitter: 'mjena')
}
}
}
}
stage('Delpoy to PROD') {
steps {
sh 'echo "Deploy to Prod"'
}
}
}
}