-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
45 lines (40 loc) · 1.65 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
def setBuildStatusBadge(project, status, color) {
def statusUri = "\'http://badges.awsp.eltoro.com?project=${project}&item=build&value=${status}&color=${color}\'"
sh "curl -sX POST ${statusUri}"
}
def slackSuccess() {
def slack_message = "Badge Server build succeeded!"
slackSend channel: '#dev-badass-badgers', message: "${slack_message}", failOnError:true, tokenCredentialId: 'slack-token', color:"good"
}
def slackFailure(){
def slack_message = "Badge Server build failed! Details: ${BUILD_URL}"
slackSend channel: '#dev-badass-badgers', message: "${slack_message}", failOnError:true, tokenCredentialId: 'slack-token', color:"danger"
}
node {
def project = "badgeserver"
def goPath = "/go/src/github.com/eltorocorp/${project}"
docker.image("golang:1.10").inside("-v ${pwd()}:${goPath} -u root") {
try {
sshagent (credentials: ['private_repo_ssh']) {
stage('Pre-Build') {
setBuildStatusBadge(project, 'pending', 'blue')
sh "chmod -R 0777 ${goPath}"
checkout scm
}
stage('Build') {
sh "cd ${goPath} && go build -o badgeserverBuild"
}
stage("Post-Build") {
setBuildStatusBadge(project, 'passing', 'green')
slackSuccess()
currentBuild.result = 'SUCCESS'
}
}
} catch (Exception err) {
sh "echo ${err}"
setBuildStatusBadge(project, 'failing', 'red')
slackFailure()
currentBuild.result = 'FAILURE'
}
}
}