github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/Jenkinsfile (about)

     1  def pipelinevars
     2  
     3  pipeline {
     4      environment {
     5          GOCACHE = "/tmp/.gocache"
     6          GOARISTA = "${WORKSPACE}/src/github.com/aristanetworks/goarista"
     7          // golangci has its own cache.
     8          GOLANGCI_LINT_CACHE = "/tmp/.golangci_cache"
     9          // PATH does not get set inside stages that use docker agents, see
    10          // https://issues.jenkins-ci.org/browse/JENKINS-49076.
    11          // withEnv won't set it either.
    12          // every sh step inside a container needs to do sh "PATH=${env.PATH} ..."
    13          // to use this PATH value instead of the PATH set by the docker image.
    14          PATH = "PATH=${PATH}:${WORKSPACE}/bin:/usr/local/go/bin "
    15      }
    16      agent { label 'jenkins-agent-cloud' }
    17      stages {
    18          stage('setup') {
    19              steps {
    20                  sh "mkdir -p ${GOARISTA}"
    21                  script {
    22                      pipelinevars = load "${WORKSPACE}/pipelinevars.groovy"
    23                  }
    24              }
    25          }
    26          stage('go test review') {
    27              agent { docker reuseNode: true, image: "${pipelinevars.goimage}" }
    28              steps {
    29                  dir("${GOARISTA}") {
    30                      checkout([
    31                          $class: 'GitSCM',
    32                          branches: [[name: '${GERRIT_REFSPEC}']],
    33                          extensions: [
    34                              [$class: 'CleanBeforeCheckout'],
    35                          ],
    36                          userRemoteConfigs: [[
    37                              url: 'https://gerrit.corp.arista.io/goarista',
    38                              refspec: '+${GERRIT_REFSPEC}:${GERRIT_REFSPEC}',
    39                          ]],
    40                      ])
    41                  }
    42                  sh 'mkdir -p $GOCACHE'
    43                  sh 'mkdir -p $GOLANGCI_LINT_CACHE'
    44                  sh 'go install golang.org/x/lint/golint@latest'
    45                  dir("${GOARISTA}") {
    46                      sh "PATH=${env.PATH} make check"
    47                  }
    48              }
    49          }
    50      }
    51  }