forked from prometheus-community/rsyslog_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
63 lines (57 loc) · 1.09 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@Library('infra-jenkins@master') _
/**
* Job Pipeline
*/
node ('ec2_vam') {
try {
stageCheckout()
stageCompile()
if (env.BRANCH_NAME == 'master') {
stageNexusUpload()
}
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stageCleanup()
}
}
def stageCheckout () {
stage('Checkout SCM') {
checkout scm
}
}
def stageCompile () {
stage('compile') {
docker.image('golang:latest').inside('-u 0:0') {
sh '''
WORKSPACE=`pwd`
mkdir /go/src/rsyslog_exporter
mv * /go/src/rsyslog_exporter
cd /go/src/rsyslog_exporter
go get
go build
mv /go/bin/rsyslog_exporter $WORKSPACE
'''
}
}
}
def stageNexusUpload(){
stage('Nexus upload') {
sendToNexus("infra-rsyslog-exporter", "rsyslog_exporter", ".")
}
}
def stageCleanup() {
stage('Clean Workspace') {
workspaceCleanup()
dir("${env.WORKSPACE}@tmp") {
deleteDir()
}
dir("${env.WORKSPACE}@script") {
deleteDir()
}
dir("${env.WORKSPACE}@script@tmp") {
deleteDir()
}
}
}