-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
92 lines (83 loc) · 2.57 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
pipeline {
agent any
environment {
imagename = "hojin19082/restful_front"
registryCredential = 'docker-hub'
dockerImage = ''
}
stages {
// git에서 repository clone
stage('Prepare') {
steps {
echo 'Clonning Repository'
git url: 'https://github.com/KA-SURFY/Comfy_Restful_front',
branch: 'master',
credentialsId: 'github_cred'
}
post {
success {
echo 'Successfully Cloned Repository'
}
failure {
error 'This pipeline stops here...'
}
}
}
// docker build
stage('Bulid Docker') {
agent any
steps {
echo 'Bulid Docker'
script {
dockerImage = docker.build imagename
}
}
post {
failure {
error 'This pipeline stops here...'
}
}
}
// docker push
stage('Push Docker') {
agent any
steps {
echo 'Push Docker'
script {
docker.withRegistry( '', registryCredential) {
dockerImage.push("${currentBuild.number}") // ex) "1.0"
}
}
}
post {
failure {
error 'This pipeline stops here...'
}
}
}
stage('Deploy to dev') {
steps {
git credentialsId: 'github_cred',
url: 'https://github.com/KA-SURFY/argocd.git',
branch: 'master'
sh "sed -i 's/restful_front:.*\$/restful_front:${currentBuild.number}/g' msa-deploy/front-deployment.yaml"
sh "git config user.name 'hojin19082'"
sh "git config user.email '905018@naver.com'"
sh "git add msa-deploy/front-deployment.yaml"
sh "git commit -m '[UPDATE] restful_front ${currentBuild.number} image versioning'"
withCredentials([gitUsernamePassword(credentialsId: 'github_cred', gitToolName: 'git-tool')]) {
sh "git remote set-url origin https://github.com/KA-SURFY/argocd"
sh "git push origin master"
}
}
post {
failure {
echo 'Update 실패ㅠㅠ'
}
success {
echo 'Update 성공!!!! test'
}
}
}
}
}