forked from Edu-TCS-DevOps-Aug21/dcpwe-javaapp-repo1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfilecicd
58 lines (48 loc) · 1.54 KB
/
Jenkinsfilecicd
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
pipeline {
agent {
label 'build_node'
}
environment {
DOCKERHUB_CREDENTIALS=credentials('dockerloginid')
}
tools
{
maven 'Maven-3.8.6'
}
stages {
stage('SCM Checkout') {
steps {
git 'https://github.com/LoksaiETA/Java-mvn-app2.git'
}
}
stage('Maven Build') {
steps {
// Run Maven on a Unix agent.
sh "mvn -Dmaven.test.failure.ignore=true clean package"
}
}
stage("Docker build"){
steps {
sh 'docker version'
sh 'docker build -t loksaidevops .'
sh 'docker image list'
sh 'docker tag loksaidevops loksaieta/loksaidevops:v1.0'
}
}
stage('Login2DockerHub') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Push2DockerHub') {
steps {
sh 'docker push loksaieta/loksaidevops:v1.0'
}
}
stage("Deploy to K8s Cluster") {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: 'kubernetes-master', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'kubectl apply -f k8s-mvn-deployment.yaml', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.yaml')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
}
}