Skip to content

Commit

Permalink
chore: try jenkins
Browse files Browse the repository at this point in the history
chore: add lint to jenkins

chore: try to fix

chore: go build cache

chore: fix

chore: fix

chore: try fix

chore: fix
  • Loading branch information
DarthPestilane committed Oct 2, 2021
1 parent eb68f81 commit 7cbe234
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
pipeline {
agent any
stages {
stage('Pre') {
steps {
sh 'env'
sh '''
mkdir -p /var/local/cache/jenkins/$JOB_NAME/go-build
mkdir -p /var/local/cache/jenkins/$JOB_NAME/go-pkg
mkdir -p /var/local/cache/jenkins/$JOB_NAME/golangci-lint
'''
}
}
stage('Build') {
steps {
sh '''
docker run --rm \
-w /var/app/ \
-v /var/local/cache/jenkins/$JOB_NAME/go-build:/root/.cache/go-build \
-v /var/local/cache/jenkins/$JOB_NAME/go-pkg:/go/pkg \
-v $WORKSPACE:/var/app/ \
-e GOPROXY="https://goproxy.cn,direct" \
-e GOSUMDB=off \
-e GO111MODULE=on \
-e CGO_ENABLED=0 \
golang:1.15-alpine \
go build -ldflags='-s' -v
'''
}
}
stage('Lint') {
steps {
sh '''
docker run --rm \
-w /var/app/ \
-v /var/local/cache/jenkins/$JOB_NAME/go-build:/root/.cache/go-build \
-v /var/local/cache/jenkins/$JOB_NAME/golangci-lint:/root/.cache/golangci-lint \
-v $WORKSPACE:/var/app/ \
-e GOPROXY="https://goproxy.cn,direct" \
-e GOSUMDB=off \
-e GO111MODULE=on \
-e CGO_ENABLED=0 \
golangci/golangci-lint:v1.42-alpine \
golangci-lint run -v
'''
}
}
stage('Test') {
steps {
sh '''
docker run --rm \
-w /var/app/ \
-v /var/local/cache/jenkins/$JOB_NAME/go-build:/root/.cache/go-build \
-v /var/local/cache/jenkins/$JOB_NAME/go-pkg:/go/pkg \
-v $WORKSPACE:/var/app/ \
-e GOPROXY="https://goproxy.cn,direct" \
-e GOSUMDB=off \
-e GO111MODULE=on \
-e CGO_ENABLED=0 \
golang:1.15-alpine \
go test -count=1 -covermode=atomic -coverprofile=.testCoverage.txt -timeout=2m -v . ./message
'''
}
}
}
}

0 comments on commit 7cbe234

Please sign in to comment.