forked from javahometech/myweb
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Jenkins-kube
65 lines (62 loc) · 1.95 KB
/
Jenkins-kube
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
pipeline{
agent any
tools {
maven 'Maven-3.6.1'
}
environment{
PATH = "/opt/maven3/bin:$PATH"
}
stages{
stage("Git Checkout"){
steps{
git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git'
}
}
stage("Maven Build"){
steps{
sh "mvn clean sonar:sonar package"
}
}
stage('Upload War To Nexus'){
steps{
nexusArtifactUploader artifacts: [
[
artifactId: 'myweb',
classifier: '',
file: "target/myweb-8.2.0.war",
type: 'war'
]
],
credentialsId: 'nexus3',
groupId: 'in.javahome',
nexusUrl: '172.31.16.243:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'sample-releases',
version: '8.2.0'
}
}
stage('Build Docker Image'){
steps{
sh 'docker build -t deepikac2021/spring-boot-mongo .'
}
}
stage('Push Docker Image'){
steps{
withCredentials([string(credentialsId: 'DOCKER_HUB_CREDENTIALS', variable: 'DOCKER_HUB_CREDENTIALS')]) {
sh "docker login -u deepikac2021 -p ${DOCKER_HUB_CREDENTIALS}"
}
sh 'docker push deepikac2021/spring-boot-mongo'
}
}
stage("Deploy To Kuberates Cluster"){
steps{
kubernetesDeploy(
configs: 'springBoot.yml',
kubeconfigId: 'KUBERNETES_CLUSTER_CONFIG',
enableConfigSubstitution: true
)
}
}
}
}