github.com/coreos/mantle@v0.13.0/Jenkinsfile (about)

     1  #!groovy
     2  
     3  properties([
     4      buildDiscarder(logRotator(daysToKeepStr: '20', numToKeepStr: '30')),
     5  
     6      [$class: 'CopyArtifactPermissionProperty',
     7       projectNames: '*'],
     8  
     9      parameters([
    10          choice(name: 'GOARCH',
    11                 choices: "amd64\narm64",
    12                 description: 'target architecture for building binaries')
    13      ]),
    14  
    15      pipelineTriggers([pollSCM('H/15 * * * *')])
    16  ])
    17  
    18  node('amd64 && docker') {
    19      stage('SCM') {
    20          checkout scm
    21      }
    22  
    23      stage('Build') {
    24          sh "docker run --rm -e CGO_ENABLED=1 -e GOARCH=${params.GOARCH} -e GOCACHE=/usr/src/myapp/cache -u \"\$(id -u):\$(id -g)\" -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v \"\$PWD\":/usr/src/myapp -w /usr/src/myapp golang:1.12 ./build"
    25      }
    26  
    27      stage('Test') {
    28          sh 'docker run --rm -e GOCACHE=/usr/src/myapp/cache -u "$(id -u):$(id -g)" -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.12 ./test'
    29      }
    30  
    31      stage('Post-build') {
    32          if (env.JOB_BASE_NAME == "master-builder") {
    33              archiveArtifacts artifacts: 'bin/**', fingerprint: true, onlyIfSuccessful: true
    34          }
    35      }
    36  }