forked from kumina/postfix_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
68 lines (62 loc) · 1.18 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
64
65
66
67
68
@Library('infra-jenkins@master') _
/**
* Job Pipeline
*/
node('ec2_vam') {
try {
stageCheckout()
stageCompile()
if (env.BRANCH_NAME == 'master') {
sendToNexus()
}
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stageCleanup()
}
}
def stageCheckout() {
stage('Checkout Repository') {
checkout scm
}
}
def stageCompile() {
stage('compile') {
docker.image('centos:7').inside('-u 0:0') {
sh '''
yum install -y epel-release
yum install -y systemd-devel
yum install -y golang
mkdir -p /go/src/postfix_exporter
mv * /go/src/postfix_exporter
export GOPATH=/go
pushd .
cd /go/src/postfix_exporter
go get
go build
popd
mv /go/bin/postfix_exporter .
'''
}
}
}
def sendToNexus() {
stage("Send to Nexus") {
sendToNexus("infra-postfix-exporter", "postfix_exporter", ".")
}
}
def stageCleanup() {
stage('Cleanup') {
cleanWs()
dir("${env.WORKSPACE}@tmp") {
deleteDir()
}
dir("${env.WORKSPACE}@script") {
deleteDir()
}
dir("${env.WORKSPACE}@script@tmp") {
deleteDir()
}
}
}