-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathJenkinsfile
44 lines (43 loc) · 1.61 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
35
36
37
38
39
40
41
42
43
44
pipeline {
agent {
node {
label 'metersphere'
}
}
options { quietPeriod(600) }
environment {
IMAGE_NAME = 'rackshift'
IMAGE_PREFIX = 'registry.cn-qingdao.aliyuncs.com/x-lab'
DOCKER = credentials('x-lab')
}
stages {
stage('Build') {
steps {
sh '''
rm -rf ${WORKSPACE}/rackshift-server/src/main/resources/static
mkdir -p ${WORKSPACE}/rackshift-server/src/main/resources/static
cd ${WORKSPACE}/rackshift-web
cnpm install
cnpm run build
cp -r ${WORKSPACE}/rackshift-web/dist/* ${WORKSPACE}/rackshift-server/src/main/resources/static
cd ${WORKSPACE}/rackshift-dhcp-proxy
mvn clean install
'''
}
}
stage('Docker build & push') {
steps {
sh '''
docker login registry.cn-qingdao.aliyuncs.com -u ${DOCKER_USR} -p ${DOCKER_PSW}
cd ${WORKSPACE}/rackshift-server
mvn clean install -DskipTests
docker build -t ${IMAGE_PREFIX}/${IMAGE_NAME}:v${BRANCH_NAME}-dev .
docker push ${IMAGE_PREFIX}/${IMAGE_NAME}:v${BRANCH_NAME}-dev
cd ${WORKSPACE}/rackshift-dhcp-proxy
docker build -t ${IMAGE_PREFIX}/rackshift-dhcp-proxy:v${BRANCH_NAME} .
docker push ${IMAGE_PREFIX}/rackshift-dhcp-proxy:v${BRANCH_NAME}
'''
}
}
}
}