-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
124 lines (114 loc) · 3.49 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
pipeline {
agent {
dockerfile {
dir '.docker/build'
additionalBuildArgs '--build-arg uid=${JENKINS_UID} --build-arg gid=${JENKINS_GID}'
args '-v ${WORKSPACE}/.docker/.m2:/home/jenkins/.m2:rw,z'
label 'docker'
}
}
options {
timestamps()
}
stages {
stage('Clean') {
steps {
dir('target') {
deleteDir()
}
}
}
stage('Generate API doc') {
steps {
dir('src/docs/asciidoc/resources/api') {
deleteDir()
sh 'echo "<h1>Hello</h1>" >> index.html'
}
// Clean the output folder
// dir('src/docs/asciidoc/resources/api') {
// deleteDir()
// sh 'echo "<h1>Hello</h1>" >> index.html'
// // Clone the repository
// // TODO:
// // npm install && npm run build:api-doc
// // TODO:
// // Move output doc to proper folder
// file = new File('index.html')
// file.append("<h1>Hello world</h1>")
// // Clean the github project
// // TODO:
// }
}
}
stage('Generate html documentation') {
steps {
sh './mvnw generate-resources -P html'
publishHTML(
reportName: 'Generated documentation',
reportDir: 'target/generated-docs',
reportFiles: 'index.html',
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: false,
reportTitles: ''
)
}
}
stage('Add preview URL in PR') {
when {
changeRequest()
}
steps {
commentGithubPR(comment: "Preview of generated documentation: ${env.JOB_URL}/Generated_20documentation/index.html", credentials: 'github-saml')
}
}
stage('Publish html documentation') {
when {
branch 'master'
}
steps {
// checkout gh-pages
dir('target/documentation') {
git(url: 'git@github.com:zetapush/documentation.git', branch: 'gh-pages')
}
// copy new documentation to gh-pages local repo
sh 'cp -rf target/generated-docs/* target/documentation'
// commit
sh 'cd target/documentation && git add .'
sh 'cd target/documentation && git commit -m "Update generated documentation"'
// push on gh-pages
sshagent(['github-ssh']) {
sh 'mkdir ~/.ssh'
sh 'ssh-keyscan github.com >> ~/.ssh/known_hosts'
sh 'cd target/documentation && git push origin gh-pages'
}
// index documents for search
withCredentials([string(credentialsId: 'algolia-documentation-admin-key', variable: 'ALGOLIA_DOCUMENTATION_ADMIN_KEY')]) {
sh "indexer index -d target/generated-docs/ -a ${env.ALGOLIA_DOCUMENTATION_APP_ID} -k ${env.ALGOLIA_DOCUMENTATION_ADMIN_KEY} -i ${env.ALGOLIA_DOCUMENTATION_INDEX}"
}
}
}
}
post {
failure {
slackSend(
message: """ZetaPush documentation : ${env.BRANCH_NAME} failed to build
- <${env.BUILD_URL}/consoleFull|View logs>""",
color: '#ff0000'
)
emailext(
subject: '${DEFAULT_SUBJECT}',
body: '${DEFAULT_CONTENT}',
attachLog: true,
recipientProviders: [[$class: 'CulpritsRecipientProvider']]
)
}
success {
slackSend(
message: """ZetaPush documentation : ${env.BRANCH_NAME} success
- <${env.BUILD_URL}/consoleFull|View logs>""",
color: '#00ff00'
)
}
}
}