-
Notifications
You must be signed in to change notification settings - Fork 24
/
Jenkinsfile-release
109 lines (95 loc) · 3.82 KB
/
Jenkinsfile-release
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
def failedBuild = false
def plugin_name = params.PLUGIN_NAME
def version = params.PLUGIN_TAG
def branch = params.BRANCH
def changeUrl = env.CHANGE_URL
def blueUrl = "${env.JOB_DISPLAY_URL}"
def message = "Release plugin ${plugin_name} ${version}"
def slackResponse = slackSend(channel: "ci", message: "${message} - <"+currentBuild.absoluteUrl+"|Link> - <"+blueUrl+"|Blue>", color: "#00A8E1")
def job = ""
def errors = []
def running = []
pipeline {
agent none
environment {
// TODO: automate
// we want it everywhere for plugins
MAVEN_ARGS = "--update-snapshots"
}
stages {
stage('Build plugin') {
// only publish nightly on dev branches
agent {
dockerfile {
filename 'ci/plugins.Dockerfile'
additionalBuildArgs "--build-arg USER_ID=${env.JENKINS_UID}"
// set same timezone as some tests rely on it
// and share maven cache
args '-v /etc/timezone:/etc/timezone:ro -v /srv/cache/elm:/home/jenkins/.elm -v /srv/cache/maven:/home/jenkins/.m2'
}
}
steps {
script {
running.add("Build")
updateSlack(errors, running, slackResponse, message, changeUrl)
makeTarget = "licensed"
if (plugin_name == "cis" || plugin_name == "openscap") {
makeTarget = ""
}
dir("${plugin_name}") {
withMaven(globalMavenSettingsConfig: "1bfa2e1a-afda-4cb4-8568-236c44b94dbf",
// don't archive jars
options: [artifactsPublisher(disabled: true)]
) {
sh script: "export PATH=$MVN_CMD_DIR:$PATH && make ${makeTarget}"
archiveArtifacts artifacts: '**/*.rpkg', fingerprint: true, onlyIfSuccessful: false, allowEmptyArchive: true
sshPublisher(publishers: [sshPublisherDesc(configName: 'publisher-01', transfers: [sshTransfer(execCommand: "/usr/local/bin/add_to_repo -r -t rpkg -v ${branch} -d /home/publisher/tmp/${plugin_name}-${branch}", remoteDirectory: "${plugin_name}-${branch}", sourceFiles: '**/*.rpkg')], verbose:true)])
}
}
running.remove("Build")
}
}
post {
failure {
script {
errors.add("Build")
updateSlack(errors, running, slackResponse, message, changeUrl)
}
}
cleanup {
script {
updateSlack(errors, running, slackResponse, message, changeUrl)
}
}
}
}
stage('End') {
steps {
script {
if (failedBuild) {
error 'End of build'
} else {
echo 'End of build'
}
}
}
}
}
}
def updateSlack(errors, running, slackResponse, message, changeUrl) {
def blueUrl = "${env.JOB_DISPLAY_URL}"
def msg ="*${message}* - <"+currentBuild.absoluteUrl+"|Link> - <"+blueUrl+"|Blue>"
def color = "#00A8E1"
if (! errors.isEmpty()) {
msg += "\n*Errors* :x: ("+errors.size()+")\n • " + errors.join("\n • ")
color = "#CC3421"
}
if (! running.isEmpty()) {
msg += "\n*Running* :arrow_right: ("+running.size()+")\n • " + running.join("\n • ")
}
if (errors.isEmpty() && running.isEmpty()) {
msg += " => All plugins built! :white_check_mark:"
color = "good"
}
slackSend(channel: slackResponse.channelId, message: msg, timestamp: slackResponse.ts, color: color)
}