-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
34 lines (25 loc) · 968 Bytes
/
Jenkinsfile
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
33
34
node {
stage('SCM Checkout') {
git credentialsId: 'git-cred', url: 'https://github.com/pantbinod/JavaAplicationUsingJenkinsDocker.git'
}
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 developerbinod/myweb:1.0.0 ."
}
stage('Push image to docker hub') {
withCredentials([string(credentialsId: 'docker-pass', variable: 'dockerpwd')]) {
sh "docker login -u developerbinod -p ${dockerpwd}"
}
sh "docker push developerbinod/myweb:1.0.0"
}
stage('Run container on Dev Server') {
def dockerRun ="docker run -d -p 8080:8080 --rm --name myweb developerbinod/myweb:1.0.0"
sshagent(['dev-server']) {
sh "ssh -o StrictHostKeyChecking=no [email protected] ${dockerRun}"
}
}
}