-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
36 lines (28 loc) · 1.08 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
#!groovy
properties([
buildDiscarder(logRotator(daysToKeepStr: '20', numToKeepStr: '30')),
[$class: 'CopyArtifactPermissionProperty',
projectNames: '*'],
parameters([
choice(name: 'GOARCH',
choices: "amd64\narm64",
description: 'target architecture for building binaries')
]),
pipelineTriggers([pollSCM('H/15 * * * *')])
])
node('amd64 && docker') {
stage('SCM') {
checkout scm
}
stage('Build') {
sh "docker run --rm -e CGO_ENABLED=1 -e GOARCH=${params.GOARCH} -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.7.1 ./build"
}
stage('Test') {
sh 'docker run --rm -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.7.1 ./test'
}
stage('Post-build') {
if (env.JOB_BASE_NAME == "master-builder") {
archiveArtifacts artifacts: 'bin/**', fingerprint: true, onlyIfSuccessful: true
}
}
}