-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.groovy
More file actions
25 lines (22 loc) · 994 Bytes
/
script.groovy
File metadata and controls
25 lines (22 loc) · 994 Bytes
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
def buildJar() {
echo "bulding the application"
sh "mvn clean package"
}
def buildImage() {
echo "building the docker image..."
withCredentials([usernamePassword(credentialsId: 'dockerhub-credential', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh 'docker build -t xuanhieu073/ems:1.0 .'
sh "echo $PASS | docker login -u $USER --password-stdin"
sh "docker push xuanhieu073/ems:1.0"
}
}
def deployApp() {
echo "deploying the application..."
// def dockerCmd = "docker run -p 8080:8080 -d xuanhieu073/demo-app:jma-2.0"
def dockerComposeCmd = "docker-compose -f docker-compose.yaml up --detach"
sshagent(['my-server-key']) {
sh "scp -v -o StrictHostKeyChecking=no docker-compose.yaml ec2-user@ec2-54-169-193-218.ap-southeast-1.compute.amazonaws.com:/home/ec2-user"
sh "ssh -o StrictHostKeyChecking=no ec2-user@ec2-54-169-193-218.ap-southeast-1.compute.amazonaws.com ${dockerComposeCmd}"
}
}
return this