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

     1  def pipelinevars
     2  
     3  // Select the SSH credentials for git operations managed by this pipeline.
     4  def credentials = "jenkins-rsa-key"
     5  
     6  pipeline {
     7      options {
     8          skipDefaultCheckout()
     9      }
    10      environment {
    11          GOPATH = "${WORKSPACE}"
    12          GOARISTA = "${GOPATH}/src/goarista"
    13          GOCACHE = "/var/cache/jenkins/.gocache"
    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                  sh "mkdir -p ${GOCACHE}"
    22                  sshagent (credentials: [credentials]) {
    23                      dir("${GOARISTA}") {
    24                          git url: 'ssh://jenkins@gerrit.corp.arista.io:29418/goarista',
    25                              credentialsId: credentials
    26                          sh "git config user.name 'Arista Jenkins'"
    27                          sh "git config user.email jenkins@arista.com"
    28                          sh "mkdir -p `git rev-parse --git-dir`/hooks/ && curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit.corp.arista.io/tools/hooks/commit-msg && chmod +x `git rev-parse --git-dir`/hooks/commit-msg"
    29                      }
    30                  }
    31                  script {
    32                      pipelinevars = load "${GOARISTA}/pipelinevars.groovy"
    33                  }
    34              }
    35          }
    36          stage("update deps") {
    37              agent { docker reuseNode: true, image: "${pipelinevars.goimage}" }
    38              steps {
    39                  sshagent (credentials: [credentials]) {
    40                      dir("${GOARISTA}") {
    41                          sh "PATH=${env.PATH} ./update_deps.sh"
    42                      }
    43                  }
    44              }
    45          }
    46          stage ("push") {
    47              steps {
    48                  sshagent (credentials: [credentials]) {
    49                      dir("${GOARISTA}") { sh "git push origin HEAD:refs/for/master" }
    50                  }
    51              }
    52          }
    53      }
    54  }