forked from javahometech/my-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
javahometech
authored
May 14, 2018
1 parent
d4c8b3d
commit 20608b9
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
} | ||
} | ||
} |