forked from centreon/centreon-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
81 lines (78 loc) · 2.29 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
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
** Variables.
*/
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
def serie = '20.04'
def maintenanceBranch = "${serie}.x"
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
} else {
env.BUILD = 'CI'
}
/*
** Pipeline code.
*/
def inputError = false
try {
node {
stage('Source') {
sh 'setup_centreon_build.sh'
dir('centreon-documentation') {
checkout scm
}
sh "./centreon-build/jobs/doc/doc-source.sh"
source = readProperties file: 'source.properties'
env.VERSION = serie
env.RELEASE = "${source.RELEASE}"
archiveArtifacts artifacts: 'assets_diff_en.txt, assets_diff_fr.txt'
}
stage('Build') {
sh "./centreon-build/jobs/doc/doc-build.sh"
stash name: 'vanilla-build', includes: 'vanilla.tar.gz'
publishHTML([
reportDir: 'preview',
reportFiles: 'index.html',
reportName: 'Centreon documentation preview'
])
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
stage('Staging') {
milestone label: 'Staging'
node {
sh 'setup_centreon_build.sh'
unstash 'vanilla-build'
sh "./centreon-build/jobs/doc/doc-staging.sh"
stash name: 'prod-build', includes: 'prod.tar.gz'
}
}
stage('Release') {
timeout(time: 1, unit: 'HOURS') {
inputError = true
input message: 'Release documentation ?', ok: 'Release'
inputError = false
}
milestone label: 'Release'
node {
sh 'setup_centreon_build.sh'
unstash 'prod-build'
sh "./centreon-build/jobs/doc/doc-release.sh"
}
}
}
} catch(e) {
if (!inputError) {
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
slackSend channel: "#documentation",
color: "#F30031",
message: "*FAILURE*: `CENTREON DOCUMENTATION` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n" +
"*COMMIT*: <https://github.com/centreon/centreon-documentation/commit/${source.COMMIT}|here> by ${source.COMMITTER}\n" +
"*INFO*: ${e}"
}
currentBuild.result = 'FAILURE'
} else {
currentBuild.result = 'SUCCESS'
}
}