forked from Edu-CKA-Jan06/Training_Documents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcicd_pipeline.txt
54 lines (48 loc) · 1.64 KB
/
cicd_pipeline.txt
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
pipeline {
agent { label 'slave1' }
tools {
maven "maven-3.6.3"
}
environment {
DOCKERHUB_CREDENTIALS=credentials('dockerloginid')
}
stages {
stage('SCM_Checkout') {
steps {
echo 'Perform SCM Checkout'
git 'https://github.com/LoksaiETA/devops-java-webapp.git'
}
}
stage('Application_Build') {
steps {
echo 'Perform Maven Build'
sh 'mvn -Dmaven.test.failure.ignore=true clean package'
}
}
stage('Build Docker Image') {
steps {
sh 'docker version'
sh "docker build -t loksaieta/loksai-eta-app:${BUILD_NUMBER} ."
sh 'docker image list'
sh "docker tag loksaieta/loksai-eta-app:${BUILD_NUMBER} loksaieta/loksai-eta-app:latest"
}
}
stage('Login2DockerHub') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Publish_to_Docker_Registry') {
steps {
sh "docker push loksaieta/loksai-eta-app:latest"
}
}
stage('Deploy to Kubernetes') {
steps {
script {
sshPublisher(publishers: [sshPublisherDesc(configName: 'Kubernetes_Cluster', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'kubectl apply -f k8smvndeployment.yaml', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.yaml')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
}
}
}