-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
67 lines (61 loc) · 2.32 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
def frontendImage
def backendImage
pipeline {
agent any
stages {
stage('Build Test') {
steps {
echo 'hello World!!'
}
}
stage('Build Backend Image') {
steps {
script {
docker.withRegistry('', 'Dockerhub') {
backendImage = docker.build("omarlaz/backend:latest")
}
}
}
post {
success {
echo 'Backend image was built successfully!!'
}
failure {
emailext body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL} <br> Stage Name: ${env.STAGE_NAME}",
mimeType: 'text/html',
subject: "ERROR CI In ${env.STAGE_NAME}: Project name -> ${env.JOB_NAME}",
to: 'jenkinsproject51@gmail.com'
}
}
}
stage('Push Backend Image') {
steps {
script {
docker.withRegistry('', 'Dockerhub') {
backendImage.push()
}
}
}
post {
success {
echo 'Pushed backend image successfully!!'
}
failure {
emailext body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL} <br> Stage Name: ${env.STAGE_NAME}",
mimeType: 'text/html',
subject: "ERROR CI In ${env.STAGE_NAME}: Project name -> ${env.JOB_NAME}",
to: 'jenkinsproject51@gmail.com'
}
}
}
stage('Apply Kubernetes files') {
steps {
withKubeConfig([credentialsId: 'apiserver', serverUrl: 'https://34.207.141.172:8443/']) {
sh 'curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.20.5/bin/linux/amd64/kubectl"'
sh 'chmod u+x ./kubectl'
sh './kubectl rollout restart deployment/api-deployment'
}
}
}
}
}