Skip to content

Commit b0e8bae

Browse files
author
javahometech
authored
Update pipeline-docker-ci-cd
1 parent f4ce505 commit b0e8bae

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pipeline-docker-ci-cd

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
node{
34
stage('Git Checkout'){
45
git url: 'https://github.com/javahometech/my-app',
@@ -16,7 +17,25 @@ node{
1617
withCredentials([string(credentialsId: 'docker-hub', variable: 'password')]) {
1718
sh "docker login -u kammana -p ${password}"
1819
}
19-
2020
sh 'docker push kammana/my-app:0.0.1'
2121
}
22+
stage('Remove Old Containers'){
23+
sshagent(['my-app-dev']) {
24+
try{
25+
def sshCmd = 'ssh -o StrictHostKeyChecking=no [email protected]'
26+
def dockerRM = 'docker rm -f my-app'
27+
sh "${sshCmd} ${dockerRM}"
28+
}catch(error){
29+
30+
}
31+
}
32+
}
33+
stage('Deploy-Dev'){
34+
sshagent(['my-app-dev']) {
35+
input 'Deploy to Dev?'
36+
def sshCmd = 'ssh -o StrictHostKeyChecking=no [email protected]'
37+
def dockerRun = 'docker run -d -p 8080:8080 --name my-app kammana/my-app:0.0.1'
38+
sh "${sshCmd} ${dockerRun}"
39+
}
40+
}
2241
}

0 commit comments

Comments
 (0)