Skip to content

Commit

Permalink
Create docker-ci-cd-youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
javahometech authored May 14, 2018
1 parent d4c8b3d commit 20608b9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docker-ci-cd-youtube
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
node{
stage('SCM Checkout'){
git credentialsId: 'git-creds', url: 'https://github.com/javahometech/my-app'
}
stage('Mvn Package'){
def mvnHome = tool name: 'maven-3', type: 'maven'
def mvnCMD = "${mvnHome}/bin/mvn"
sh "${mvnCMD} clean package"
}
stage('Build Docker Image'){
sh 'docker build -t kammana/my-app:2.0.0 .'
}
stage('Push Docker Image'){
withCredentials([string(credentialsId: 'docker-pwd', variable: 'dockerHubPwd')]) {
sh "docker login -u kammana -p ${dockerHubPwd}"
}
sh 'docker push kammana/my-app:2.0.0'
}
stage('Run Container on Dev Server'){
def dockerRun = 'docker run -p 8080:8080 -d --name my-app kammana/my-app:2.0.0'
sshagent(['dev-server']) {
sh "ssh -o StrictHostKeyChecking=no [email protected] ${dockerRun}"
}
}
}

0 comments on commit 20608b9

Please sign in to comment.