forked from Rosalita/GoViolin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
52 lines (44 loc) · 1.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
pipeline {
agent { label 'controller-node' }
environment {
DOCKER_USERNAME = credentials('docker-username')
DOCKER_PASSWORD = credentials('docker-password')
}
stages {
stage('Build Image') {
steps {
sh 'docker build -t $DOCKER_USERNAME/go-violin-app:latest .'
}
}
stage('Login into dockerhub') {
steps {
sh 'docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD'
}
}
stage('Push to docker repository') {
steps {
sh 'docker push $DOCKER_USERNAME/go-violin-app:latest'
}
}
stage('Deploy app to Kubernetes cluster') {
steps {
sh "kubectl apply --kubeconfig=${params.kubeConfig} -f kubernetes/deployment.yaml -f kubernetes/service.yaml"
}
}
}
post {
always {
sh 'docker logout'
}
failure {
mail to: "[email protected]",
subject: "jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found here: ${env.BUILD_URL}"
}
success {
mail to: "[email protected]",
subject: "jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found here: ${env.BUILD_URL}"
}
}
}