-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathJenkinsfile
51 lines (50 loc) · 1.89 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
def pipelinevars
pipeline {
environment {
GOCACHE = "/tmp/.gocache"
GOARISTA = "${WORKSPACE}/src/github.com/aristanetworks/goarista"
// golangci has its own cache.
GOLANGCI_LINT_CACHE = "/tmp/.golangci_cache"
// PATH does not get set inside stages that use docker agents, see
// https://issues.jenkins-ci.org/browse/JENKINS-49076.
// withEnv won't set it either.
// every sh step inside a container needs to do sh "PATH=${env.PATH} ..."
// to use this PATH value instead of the PATH set by the docker image.
PATH = "PATH=${PATH}:${WORKSPACE}/bin:/usr/local/go/bin "
}
agent { label 'jenkins-agent-cloud' }
stages {
stage('setup') {
steps {
sh "mkdir -p ${GOARISTA}"
script {
pipelinevars = load "${WORKSPACE}/pipelinevars.groovy"
}
}
}
stage('go test review') {
agent { docker reuseNode: true, image: "${pipelinevars.goimage}" }
steps {
dir("${GOARISTA}") {
checkout([
$class: 'GitSCM',
branches: [[name: '${GERRIT_REFSPEC}']],
extensions: [
[$class: 'CleanBeforeCheckout'],
],
userRemoteConfigs: [[
url: 'https://gerrit.corp.arista.io/goarista',
refspec: '+${GERRIT_REFSPEC}:${GERRIT_REFSPEC}',
]],
])
}
sh 'mkdir -p $GOCACHE'
sh 'mkdir -p $GOLANGCI_LINT_CACHE'
sh 'go install golang.org/x/lint/golint@latest'
dir("${GOARISTA}") {
sh "PATH=${env.PATH} make check"
}
}
}
}
}