-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeploy war file to remote docker container using cicd
52 lines (42 loc) · 1.53 KB
/
Deploy war file to remote docker container using cicd
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
pipeline {
agent any
stages{
stage ('clone the repo')
{
steps {
git branch: 'master', url:'https://github.com/gautham73/mvnproj.git'
}
}
stage ('build the file') {
steps {
sh "mvn package "
}
}
stage ('build the image'){
steps {
sh 'docker build -t mydocimg:latest .'
sh 'docker tag mydocimg gautham73kumar/mydocimg:latest'
}
}
stage ('push the image to docker hub') {
steps {
withDockerRegistry(credentialsId: 'dockerhub', url: "") {
sh "docker push gautham73kumar/mydocimg"
}
}
}
stage ('docker image run on jenkins server') {
steps
{
sh 'docker run -d -p 8090:8080 gautham73kumar/mydocimg'
}
}
stage ('run docker image on remote host')
{
steps {
sh "docker -H ssh://[email protected] pull gautham73kumar/mydocimg"
sh "docker -H ssh://[email protected] run -d -p 8080:8080 gautham73kumar/mydocimg"
}
}
}
}