-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
69 lines (57 loc) · 1.77 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
#!groovy
// keep 20 builds history
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '20']]]);
def lib = library('ci-shared-libs').com.starup
def msgUtils = lib.MessageLego.new()
def buildAgent = 'docker-build-bj3a'
def dockerHub = 'registry.astarup.com/astarup'
def projectName = 'debian-stretch'
buildHttpProxy = "http://proxy_hk.astarup.com:39628"
currentBuild.result = "SUCCESS"
imageName = "${dockerHub}/${projectName}"
imageTag = ''
versionTagRegex = /^ruby(\d+\.){0,2}\d+$/
def commitMsg = ''
def branch = env.BRANCH_NAME
def bearychatHookUrl = env.BEARYCHAT_HOOK_URL
def bearychatHookGroup = 'ci'
def kubeTestNs = 'test'
def kubeQaNs = 'qa'
def kubeStageNs = 'staging'
def kubeProdNs = 'production'
def Object image
/*
Jenkinsfile main body
*/
try {
node("${buildAgent}") {
stage("Checkout Project") {
def scmVars = checkout scm
imageTag = genImageTag(env.BRANCH_NAME)
}
stage("Build Image") {
image = dockerBuild("${imageName}","${buildHttpProxy}")
}
}
if (branch ==~ versionTagRegex) {
stage("Publish Image to Registry") {
node("${buildAgent}") {
dockerPush(image,"$imageTag")
}
}
}
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
node("${buildAgent}") {
echo e.getCauses().join(", ")
currentBuild.result = "ABORTED"
errorMsg = msgUtils.errorMsg("${aborteMsg}")
bearyNotifySend attachments: "${errorMsg}", channel: "${bearychatHookGroup}", endpoint: "${bearychatHookUrl}"
}
} catch (err) {
node("${buildAgent}") {
currentBuild.result = "FAILURE"
errorMsg = msgUtils.errorMsg(err,'')
bearyNotifySend attachments: "${errorMsg}", channel: "${bearychatHookGroup}", endpoint: "${bearychatHookUrl}"
throw err
}
}