forked from DukeNLIDB/NLIDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
34 lines (34 loc) · 1.43 KB
/
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
pipeline {
agent any
stages {
stage('Test') {
steps {
sh '''#!/bin/bash
docker build -t nlidb/test --file=Dockerfile.test ${WORKSPACE}
docker run nlidb/test
docker rm $(docker ps -aq --filter status=exited)
docker rmi $(docker images -aq --filter dangling=true)
'''
}
}
stage('Deploy') {
when {
branch 'master'
}
steps {
sh '''#!/bin/bash
docker build -t nlidb/main --file=Dockerfile ${WORKSPACE}
docker save -o /tmp/nlidb-main.img nlidb/main
echo scping the image file...
scp -o "StrictHostKeyChecking no" -i $HOME/.ssh/aws-keping94-us-east1.pem /tmp/nlidb-main.img centos@34.231.141.223:/home/centos/
echo stopping and removing the previously running nlidb container
ssh -o "StrictHostKeyChecking no" -i $HOME/.ssh/aws-keping94-us-east1.pem centos@34.231.141.223 'docker stop $(docker ps -aq --filter ancestor=nlidb/main)'
ssh -o "StrictHostKeyChecking no" -i $HOME/.ssh/aws-keping94-us-east1.pem centos@34.231.141.223 'docker rm $(docker ps -aq --filter ancestor=nlidb/main)'
ssh -o "StrictHostKeyChecking no" -i $HOME/.ssh/aws-keping94-us-east1.pem centos@34.231.141.223 'docker rmi $(docker images -aq --filter dangling=true)'
echo loading the new image and start the container
ssh -o "StrictHostKeyChecking no" -i $HOME/.ssh/aws-keping94-us-east1.pem centos@34.231.141.223 'docker load -i nlidb-main.img; docker run -d -p 8080:80 nlidb/main;'
'''
}
}
}
}