-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile
51 lines (51 loc) · 1.3 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
pipeline {
agent none
stages {
stage('Source Code') {
agent { label 'test' }
steps {
git 'https://github.com/hemanth22/Capstone.git'
}
}
stage('Build') {
agent { label 'test' }
steps {
sh "docker build -t intellipaat:1.0 ."
}
}
stage('Run container') {
agent { label 'test' }
steps {
sh "docker run -d -p 80:80 --name=intellipaat intellipaat:1.0"
}
}
stage('Website test') {
agent { label 'test' }
steps {
sh "hostname -I"
sh "curl -I localhost:80"
sh "ansible-playbook webchecker.yml"
sh "java -jar website-testcase.jar"
}
}
stage('clean test server') {
agent { label 'test' }
steps {
sh "docker rm -f \$(docker ps -q)"
sh "docker rmi -f \$(docker images -q)"
}
}
stage('Deploy to prod server') {
agent { label 'prod' }
when {
branch 'master'
}
steps {
git 'https://github.com/hemanth22/Capstone.git'
sh "hostname -I"
sh "ansible-playbook cleandocker.yaml"
sh "ansible-playbook deploydocker.yaml"
}
}
}
}