Skip to content

Commit 27986cd

Browse files
committed
add jenkinsfile
1 parent 31ef1ef commit 27986cd

File tree

4 files changed

+90
-62
lines changed

4 files changed

+90
-62
lines changed

.gitignore

Lines changed: 0 additions & 22 deletions
This file was deleted.

Jenkinsfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
def label = "buildpod.${env.JOB_NAME}".replaceAll(/[^A-Za-z-]+/, '-').take(62) + "p"
2+
3+
podTemplate(
4+
name: label,
5+
label: label,
6+
containers: [
7+
containerTemplate(
8+
name: 'build-golang',
9+
image: 'docker.io/bborbe/build-golang:1.0.0',
10+
ttyEnabled: true,
11+
command: 'cat',
12+
resourceRequestCpu: '500m',
13+
resourceRequestMemory: '500Mi',
14+
resourceLimitCpu: '2000m',
15+
resourceLimitMemory: '500Mi',
16+
),
17+
],
18+
volumes: [],
19+
inheritFrom: '',
20+
namespace: 'jenkins',
21+
serviceAccount: '',
22+
workspaceVolume: emptyDirWorkspaceVolume(false),
23+
) {
24+
node(label) {
25+
properties([
26+
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '3', numToKeepStr: '5')),
27+
pipelineTriggers([
28+
cron('H 2 * * *'),
29+
pollSCM('H/5 * * * *'),
30+
]),
31+
])
32+
try {
33+
container('build-golang') {
34+
stage('Golang Checkout') {
35+
timeout(time: 5, unit: 'MINUTES') {
36+
checkout([
37+
$class: 'GitSCM',
38+
branches: scm.branches,
39+
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
40+
extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: true]],
41+
submoduleCfg: [],
42+
userRemoteConfigs: scm.userRemoteConfigs
43+
])
44+
}
45+
}
46+
stage('Golang Link') {
47+
timeout(time: 5, unit: 'MINUTES') {
48+
sh """
49+
mkdir -p /go/src/github.com/bborbe
50+
ln -s `pwd` /go/src/github.com/bborbe/webdriver
51+
"""
52+
}
53+
}
54+
stage('Golang Test') {
55+
timeout(time: 15, unit: 'MINUTES') {
56+
sh "cd /go/src/github.com/bborbe/webdriver && make test"
57+
}
58+
}
59+
}
60+
currentBuild.result = 'SUCCESS'
61+
} catch (any) {
62+
currentBuild.result = 'FAILURE'
63+
throw any //rethrow exception to prevent the build from proceeding
64+
} finally {
65+
if ('FAILURE'.equals(currentBuild.result)) {
66+
emailext(
67+
body: '${DEFAULT_CONTENT}',
68+
mimeType: 'text/html',
69+
replyTo: '$DEFAULT_REPLYTO',
70+
subject: '${DEFAULT_SUBJECT}',
71+
to: emailextrecipients([
72+
[$class: 'CulpritsRecipientProvider'],
73+
[$class: 'RequesterRecipientProvider']
74+
])
75+
)
76+
}
77+
}
78+
}
79+
}

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
default: test
2+
3+
test:
4+
go test -cover -race $(shell go list ./... | grep -v /vendor/)
5+
6+
goimports:
7+
go get golang.org/x/tools/cmd/goimports
8+
9+
format: goimports
10+
find . -type f -name '*.go' -not -path './vendor/*' -exec gofmt -w "{}" +
11+
find . -type f -name '*.go' -not -path './vendor/*' -exec goimports -w "{}" +

build.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)