-
Notifications
You must be signed in to change notification settings - Fork 50
/
Jenkinsfile
95 lines (85 loc) · 2.95 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
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
pipeline {
agent {
kubernetes {
inheritFrom "build-go code-scan xuanim"
}
}
stages {
stage("Prepare") {
environment {
GOPROXY = "https://goproxy.cn,direct"
}
steps {
container('golang') {
sh "sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories"
sh "apk --no-cache add make git gcc libc-dev"
sh 'go mod download'
sh 'go install -a -v github.com/go-bindata/go-bindata/...@latest'
sh 'go-bindata -o=res/res.go -pkg=res res/...'
}
}
}
stage("Test") {
parallel {
stage("UnitTest") {
steps {
container('golang') {
sh 'CGO_ENABLED=0 go test ./...'
}
}
post {
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ce)" --title "zendata unit test failure" --url "${BUILD_URL}" --content "zendata unit test failure, please check it" --debug --custom'
}
}
}
} // End UnitTest
stage("SonarScan") {
steps {
container('sonar') {
withSonarQubeEnv('sonarqube') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh 'git config --global --add safe.directory $(pwd)'
sh 'sonar-scanner -Dsonar.analysis.user=$(git show -s --format=%ae)'
}
}
}
}
post {
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ce)" --title "zendata sonar scan failure" --url "${BUILD_URL}" --content "zendata sonar scan failure, please check it" --debug --custom'
}
}
}
} // End SonarScan
}
}
stage("Build") {
steps {
container('golang') {
sh 'git config --global --add safe.directory $(pwd)'
sh 'CGO_ENABLED=0 make compile_command_linux'
sh 'ls bin/linux/'
}
}
post {
success {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ce)" --title "zendata build success" --url "${BUILD_URL}" --content "zendata build success" --debug --custom'
}
}
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ce)" --title "zendata build failure" --url "${BUILD_URL}" --content "zendata build failure, please check it" --debug --custom'
}
}
}
} // End Build
}
}