-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
83 lines (82 loc) · 2.66 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
pipeline {
agent any
triggers {
githubPush()
}
options {
timestamps()
}
stages {
stage('Github Repository Clone & Checkout') {
steps {
git branch: 'docker',
url: 'https://github.com/devlukej/jenkins-cicd.git',
credentialsId: 'jenkins'
}
}
stage('Docker Build') {
steps {
script{
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub') {
// Dockerfile로 이미지 생성
docker.build('jochanho/jenkins-test', './docker')
// docker build -t <계정명>/<리포지토리명|이미지명>:<태그|버전>
}
}
}
}
stage('dockerfile_example') {
steps {
git branch: 'main',
url: 'https://github.com/devlukej/dockerfile_example.git',
credentialsId: 'test'
}
}
stage('apache2 Build') {
steps {
script{
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub') {
docker.build('jochanho/lb_apache2', './ubuntu_apache2')
}
}
}
}
stage('nginx Build') {
steps {
script{
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub') {
docker.build('jochanho/lb_apache2', './ubuntu_nginx')
}
}
}
}
stage('LB Build') {
steps {
script{
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub') {
docker.build('jochanho/lb_apache2', './ubuntu_nginx_loadbalancer')
}
}
}
}
stage('Docker Image Push'){
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub') {
def img = docker.image('jochanho/jenkins-test')
img.push('latest')
img.push('0.1')
}
}
}
}
}
post{
cleanup {
emailext subject: '[$JOB_NAME - $BUILD_DISPLAY_NAME] - 작업 결과',
to: '[email protected]', //받는사람
body: '$JOB_NAME\n\n작업이 수행되었습니다.\n\n$BUILD_URL \n\n$DEFAULT_CONTENT'
// cleanWs() //작업영역 삭제
}
}
}