github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/Jenkinsfile (about) 1 pipeline { 2 agent { 3 kubernetes { 4 inheritFrom "build-go code-scan xuanim" 5 } 6 } 7 8 stages { 9 stage("Prepare") { 10 environment { 11 GOPROXY = "https://goproxy.cn,direct" 12 } 13 14 steps { 15 container('golang') { 16 sh "sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories" 17 sh "apk --no-cache add make git gcc libc-dev" 18 sh 'go mod download' 19 sh 'go install -a -v github.com/go-bindata/go-bindata/...@latest' 20 sh 'go-bindata -o=res/res.go -pkg=res res/...' 21 } 22 } 23 } 24 25 stage("Test") { 26 parallel { 27 stage("UnitTest") { 28 steps { 29 container('golang') { 30 sh 'CGO_ENABLED=0 go test ./...' 31 } 32 } 33 34 post { 35 failure { 36 container('xuanimbot') { 37 sh 'git config --global --add safe.directory $(pwd)' 38 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' 39 } 40 } 41 } 42 } // End UnitTest 43 44 stage("SonarScan") { 45 steps { 46 container('sonar') { 47 withSonarQubeEnv('sonarqube') { 48 catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { 49 sh 'git config --global --add safe.directory $(pwd)' 50 sh 'sonar-scanner -Dsonar.analysis.user=$(git show -s --format=%ae)' 51 } 52 } 53 } 54 } 55 56 post { 57 failure { 58 container('xuanimbot') { 59 sh 'git config --global --add safe.directory $(pwd)' 60 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' 61 } 62 } 63 } 64 } // End SonarScan 65 } 66 } 67 68 stage("Build") { 69 steps { 70 container('golang') { 71 sh 'git config --global --add safe.directory $(pwd)' 72 sh 'CGO_ENABLED=0 make compile_command_linux' 73 sh 'ls bin/linux/' 74 } 75 } 76 77 post { 78 success { 79 container('xuanimbot') { 80 sh 'git config --global --add safe.directory $(pwd)' 81 sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ce)" --title "zendata build success" --url "${BUILD_URL}" --content "zendata build success" --debug --custom' 82 } 83 } 84 failure { 85 container('xuanimbot') { 86 sh 'git config --global --add safe.directory $(pwd)' 87 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' 88 } 89 } 90 } 91 92 } // End Build 93 94 } 95 }