forked from crawlab-team/crawlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
56 lines (55 loc) · 1.47 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
45
46
47
48
49
50
51
52
53
54
55
56
pipeline {
agent {
node {
label 'crawlab'
}
}
stages {
stage('Setup') {
steps {
echo "Running Setup..."
script {
if (env.GIT_BRANCH == 'develop') {
env.TAG = 'develop'
env.DOCKERFILE = 'Dockerfile.local'
} else if (env.GIT_BRANCH == 'master') {
env.TAG = 'master'
env.DOCKERFILE = 'Dockerfile.local'
}
}
}
}
stage('Build') {
steps {
echo "Building..."
sh """
docker build -t tikazyq/crawlab:${ENV:TAG} -f ${ENV:DOCKERFILE} .
"""
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
sh """
# 重启docker compose
cd ./jenkins/${ENV:GIT_BRANCH}
docker-compose down | true
docker-compose up -d | true
"""
}
}
stage('Cleanup') {
steps {
echo 'Cleanup...'
sh """
docker rmi -f `docker images | grep '<none>' | grep -v IMAGE | awk '{ print \$3 }' | xargs`
"""
}
}
}
}