forked from Java-Techie-jt/devops-automation
-
Notifications
You must be signed in to change notification settings - Fork 132
/
Jenkinsfile
41 lines (38 loc) · 1.17 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
pipeline {
agent any
tools{
maven 'maven'
}
stages{
stage('Build Maven'){
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/sureshrajuvetukuri/devops-automation.git']]])
sh 'mvn clean install'
}
}
stage('Build docker image'){
steps{
script{
sh 'docker build -t suresh394/kubernetes .'
}
}
}
stage('Push image to hub'){
steps{
script{
withCredentials([string(credentialsId: 'dockerhubpwd', variable: 'dockerhubpwd')]) {
sh 'docker login -u suresh394 -p ${dockerhubpwd}'
}
sh 'docker push suresh394/kubernetes'
}
}
}
stage('Deploy to K8s'){
steps{
script{
kubernetesDeploy (configs: 'deploymentservice.yaml',kubeconfigId: 'kubeconfig')
}
}
}
}
}