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
Sep 4, 2018
1 parent
b5d7034
commit 80f1074
Showing
1 changed file
with
39 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,39 @@ | ||
node{ | ||
stage('Git Checkout'){ | ||
git 'https://github.com/javahometech/my-app' | ||
} | ||
stage('Maven Package'){ | ||
sh 'mvn clean package' | ||
sh 'mv target/myweb*.war target/myweb.war' | ||
} | ||
|
||
stage('Build Docker Imager'){ | ||
sh 'docker build -t kammana/myweb:0.0.1 .' | ||
} | ||
|
||
stage('Push to Docker Hub'){ | ||
|
||
withCredentials([string(credentialsId: 'github-pwd', variable: 'dockerHubPwd')]) { | ||
sh "docker login -u kammana -p ${dockerHubPwd}" | ||
} | ||
sh 'docker push kammana/myweb:0.0.1' | ||
} | ||
stage('Remove Previous Container'){ | ||
try{ | ||
def dockerRm = 'docker rm -f myweb' | ||
sshagent(['docker-dev']) { | ||
sh "ssh -o StrictHostKeyChecking=no [email protected] ${dockerRm}" | ||
} | ||
}catch(error){ | ||
// do nothing if there is an exception | ||
} | ||
} | ||
stage('Deploy to Dev Environment'){ | ||
def dockerRun = 'docker run -d -p 8080:8080 --name myweb kammana/myweb:0.0.1 ' | ||
sshagent(['docker-dev']) { | ||
sh "ssh -o StrictHostKeyChecking=no [email protected] ${dockerRun}" | ||
} | ||
|
||
} | ||
|
||
} |