-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathJenkinsfile
More file actions
106 lines (96 loc) · 3.25 KB
/
Jenkinsfile
File metadata and controls
106 lines (96 loc) · 3.25 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pipeline {
agent any
environment {
GOPATH = "${WORKSPACE}"
GO111MODULE = "on"
PROJ_DIR = "${WORKSPACE}/src/github.com/33cn/plugin"
}
options {
timeout(time: 2,unit: 'HOURS')
retry(1)
timestamps()
gitLabConnection('gitlab33')
gitlabBuilds(builds: ['check'])
checkoutToSubdirectory "src/github.com/33cn/plugin"
}
tools {go 'go'}
stages {
stage('deploy') {
steps {
dir("${PROJ_DIR}"){
gitlabCommitStatus(name: 'deploy'){
sh '''
set -e
go version
make build_ci
cd build
rm -rf "${BUILD_NUMBER}"
mkdir -p "${BUILD_NUMBER}"
cp -r ci/* "${BUILD_NUMBER}/"
./docker-compose-pre.sh modify
cp chain33* Dockerfile* docker-compose* *.sh "${BUILD_NUMBER}/"
cd "${BUILD_NUMBER}"
rm -rf cross2eth mix rgbx rollup|| true
./docker-compose-pre.sh run "${BUILD_NUMBER}" all
'''
}
}
}
post {
always {
dir("${PROJ_DIR}"){
sh '''
set +e
cd build
if [ -d "${BUILD_NUMBER}" ]; then
cd "${BUILD_NUMBER}"
./docker-compose-pre.sh down "${BUILD_NUMBER}" all || true
cd ..
rm -rf "${BUILD_NUMBER}"
fi
cd ..
make clean || true
'''
}
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
// clean up our workspace
deleteDir()
}
success {
echo 'I succeeeded!'
echo "email user: ${ghprbActualCommitAuthorEmail}"
script{
try {
mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Successed Pipeline: ${currentBuild.fullDisplayName}",
body: "this is success with ${env.BUILD_URL}"
}
catch (err){
echo 'email err'
}
currentBuild.result = 'SUCCESS'
}
echo 'SUCCESS'
}
failure {
echo 'I failed '
echo "email user: ${ghprbActualCommitAuthorEmail}"
script{
try {
mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}catch (err){
echo 'email err'
}
}
echo currentBuild.result
}
}
}