-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
57 lines (56 loc) · 1.79 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
#!/usr/bin/env groovy
pipeline {
agent {
docker {
image 'golang:1.13'
}
}
environment {
GOBIN = '/tmp/go-bin'
GOCACHE = '/tmp/go-build'
}
stages {
stage('Bootstrap') {
steps {
echo 'Bootstrapping..'
sh 'go version'
sh 'go get -v golang.org/x/lint/golint'
sh 'go get -v github.com/tebeka/go2xunit'
sh 'go get -v github.com/axw/gocov/...'
sh 'go get -v github.com/AlekSi/gocov-xml'
sh 'go mod vendor'
}
}
stage('Lint') {
steps {
echo 'Linting..'
sh 'PATH=$PATH:$GOBIN golint | tee golint.txt || true'
sh 'go vet | tee govet.txt || true'
recordIssues qualityGates: [[threshold: 100, type: 'TOTAL', unstable: true]], tools: [goVet(pattern: 'govet.txt'), goLint(pattern: 'golint.txt')]
}
}
stage('Test') {
steps {
echo 'Testing..'
sh 'PATH=$PATH:$GOBIN go test -v -count=1 -covermode=atomic -coverprofile=coverage.out | tee tests.output'
sh 'PATH=$PATH:$GOBIN go2xunit -fail -input tests.output -output tests.xml'
junit allowEmptyResults: true, testResults: 'tests.xml'
}
}
stage('Coverage') {
steps {
echo 'Coverage..'
sh 'mkdir -p ./test/reports'
sh 'go tool cover -html=coverage.out -o test/reports/coverage.html'
sh 'PATH=$PATH:$GOBIN; gocov convert coverage.out | gocov-xml > coverage.xml'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'test/reports', reportFiles: 'coverage.html', reportName: 'Go Coverage Report HTML', reportTitles: ''])
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
}
}
post {
always {
cleanWs()
}
}
}