-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
docker-ci-cd
32 lines (27 loc) · 854 Bytes
/
docker-ci-cd
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
node{
stage('SCM Checkout'){
git branch: 'master',
credentialsId: 'javahometech',
url: 'https://github.com/javahometech/myweb'
}
stage('Maven Build'){
def mvnHome = tool name: 'maven3', type: 'maven'
sh "${mvnHome}/bin/mvn clean package"
sh 'mv target/myweb*.war target/myweb.war'
}
stage('Build Docker Image'){
sh 'docker build -t kammana/myweb:5.0.0 .'
}
stage('Upload To DockerHub'){
sh "docker login -u kammana -p Cloud@1234"
sh "docker push kammana/myweb:5.0.0"
}
stage('Deploy to Dev'){
sshagent(['tomcat-dev']) {
def dockeRm = "ssh ec2-user@172.31.14.131 docker rm -f myweb"
def dockeRun = "ssh ec2-user@172.31.14.131 docker run -d -p 80:8080 --name myweb kammana/myweb:5.0.0"
sh "${dockeRm}"
sh "${dockeRun}"
}
}
}