forked from mallanagouda4/java-web-app-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
51 lines (33 loc) · 1.57 KB
/
Jenkinsfile
File metadata and controls
51 lines (33 loc) · 1.57 KB
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
node{
def Maven_Home= tool name: 'maven-3.6.1',type: 'maven'
stage('gitcheckout'){
git credentialsId: '5e7cfcb2-a74a-485d-9e74-168e3683b0ea', url: 'https://github.com/mallanagouda4/java-web-app-docker.git'
}
stage ('Build'){
sh "${Maven_Home}/bin/mvn clean package"
}
stage ('imgbuild'){
sh "docker build -t 13.127.217.37:8083/gichgiligili:$BUILD_NUMBER ."
}
stage ('dockerpush'){
withCredentials([string(credentialsId: 'nexusid', variable: 'pwd')]) {
sh "docker login -u admin -p ${pwd} 13.127.217.37:8083 "
sh " docker push 13.127.217.37:8083/gichgiligili:$BUILD_NUMBER"
}
}
stage ('pullimg'){
withCredentials([string(credentialsId: 'nexusid', variable: 'pwd')]) {
// sh "docker login -u admin -p ${pwd} 13.127.217.37:8083 "
sh " docker pull 13.127.217.37:8083/gichgiligili:$BUILD_NUMBER"
}
}
stage('deployment'){
def dockerRun = 'docker run -d -p 8080:8080 --name maven-web-docerimage 13.127.217.37:8083/gichgiligili:$BUILD_NUMBER'
sshagent(['pemkey']) {
sh 'ssh -o StrictHostKeyChecking=no [email protected] docker stop maven-web-docerimage || true'
sh 'ssh [email protected] docker rm maven-web-docerimage || true'
sh 'ssh [email protected] docker rmi -f $(docker images -q) || true'
sh "ssh [email protected] ${dockerRun}"
}
}
}