-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
105 lines (85 loc) ยท 2.48 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
pipeline {
agent any
triggers {
pollSCM('*/3 * * * *')
}
environment {
AWS_ACCESS_KEY_ID = credentials('awsAccessKeyId')
AWS_SECRET_ACCESS_KEY = credentials('awsSecretAccessKey')
AWS_DEAFAULT_REGION = 'ap-northeast-2'
}
stages {
stage('Prepare'){
agent any
steps {
echo "Clonning Repository"
git url: 'https://github.com/When-You-Come-Merona-Dev/GRank-Server.git',
branch: 'develop',
credentialsId: 'tokenforjenkins'
}
post {
success{
echo "Successfully cloned Repository"
}
always {
echo "I tried..."
}
cleanup {
echo "after all other post condition"
}
failure {
error 'This pipeline stops here...'
}
}
}
stage('Build') {
agent any
steps{
echo 'build'
dir('.'){
sh """
sudo docker build . -t grank-server
"""
}
}
post {
success{
echo "Successfully cloned Repository"
}
always {
echo "I tried..."
}
cleanup {
echo "after all other post condition"
}
failure {
error 'This pipeline stops here...'
}
}
}
stage('Deploy') {
agent any
steps {
echo 'Stop and Remove existed container'
sh '''
sudo docker stop -f $(docker ps -aq) || true && sudo docker rm -f $(docker ps -aq) || true
sudo docker run -p 80:3052 -d grank-server
'''
}
post {
success{
echo "Successfully cloned Repository"
}
always {
echo "I tried..."
}
cleanup {
echo "after all other post condition"
}
failure {
error 'This pipeline stops here...'
}
}
}
}
}