forked from Srikanthkittane/hello-world-war
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile6
37 lines (36 loc) · 1.98 KB
/
Jenkinsfile6
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
pipeline {
agent none
stages {
stage ( 'my build' ) {
agent { label 'jenkins'}
steps {
sh 'pwd'
sh 'whoami'
sh "echo ${BUILD_VERSION}"
sh 'docker build -t tomcat/build:${BUILD_VERSION} --build-arg BUILD_VERSION=${BUILD_VERSION} .'
sh 'helm package ./helm/tomcat-helm --version=${BUILD_VERSION}'
}
}
stage ( 'publish' ) {
agent { label 'jenkins'}
steps {
sh "echo ${BUILD_VERSION}"
withCredentials([usernamePassword(credentialsId: 'Docker_hub', passwordVariable: 'Docker_hubPassword', usernameVariable: 'Docker_hubUser')]) {
sh "docker login -u ${env.Docker_hubUser} -p ${env.Docker_hubPassword}"
sh 'docker tag tomcat/build:${BUILD_VERSION} girishharugeri/my_tomcat:${BUILD_VERSION}'
sh 'docker push girishharugeri/my_tomcat:${BUILD_VERSION}'
sh 'curl -uharugeri.girish@gmail.com:girishha@Jfrog7 -T tomcat-helm-${BUILD_VERSION}.tgz \"https://girishha.jfrog.io/artifactory/helm/tomcat-helm-${BUILD_VERSION}.tgz\"'
}
}
}
stage ( 'my deploy' ) {
agent { label 'k8s_master' }
steps {
sh 'helm repo add helm https://girishha.jfrog.io/artifactory/api/helm/helm --username harugeri.girish@gmail.com --password girishha@Jfrog7'
sh 'helm repo update'
sh 'helm repo list'
sh 'helm upgrade --install mytomcat helm/tomcat-helm --version=${BUILD_VERSION} --set selector_label=tomcat --set deployment_name=tomcat-deployment --set replicas=2 --set registry_name=girishharugeri --set repository_name=my_tomcat --set tag=${BUILD_VERSION} --set targetport=8080 --set port=8080'
}
}
}
}