-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathgenerate-hbase-website.Jenkinsfile
More file actions
134 lines (132 loc) · 4.57 KB
/
generate-hbase-website.Jenkinsfile
File metadata and controls
134 lines (132 loc) · 4.57 KB
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
125
126
127
128
129
130
131
132
133
134
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
pipeline {
agent {
node {
label 'hbase'
}
}
triggers {
pollSCM('@daily')
}
options {
buildDiscarder(logRotator(numToKeepStr: '30'))
timeout (time: 1, unit: 'HOURS')
timestamps()
skipDefaultCheckout()
disableConcurrentBuilds()
}
parameters {
booleanParam(name: 'DEBUG', defaultValue: false, description: 'Produce a lot more meta-information.')
booleanParam(name: 'FORCE_FAIL', defaultValue: false, description: 'force a failure to test notifications.')
}
stages {
stage ('build hbase website') {
steps {
dir('component') {
checkout scm
}
sh '''#!/bin/bash -e
if [ "${DEBUG}" = "true" ]; then
set -x
fi
if [ "${FORCE_FAIL}" = "true" ]; then
false
fi
user=$(whoami)
docker build -t hbase-build-website -f "${WORKSPACE}/component/dev-support/docker/Dockerfile" .
docker run --rm -v "${WORKSPACE}":/home/${user} -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro \
-u `id -u`:`id -g` -e JAVA_HOME="/usr/lib/jvm/java-17" -e GIT_AUTHOR_NAME="HBase" \
-e GIT_AUTHOR_EMAIL="dev@hbase.apache.org" -e GIT_COMMITTER_NAME="HBase" \
-e GIT_COMMITTER_EMAIL="dev@hbase.apache.org" --workdir=/home/${user} hbase-build-website \
"component/dev-support/generate-website/build-hbase-website.sh" \
--working-dir /home/${user} component
'''
script {
if (fileExists('website.patch.zip')) {
sh'''#!/bin/bash -e
patch=$(ls -1 *.patch | head -n 1)
echo "Has patch ${patch}, stash and then publish"
'''
stash name: 'patch', includes: "*.patch"
env.PUBLISH_WEBSITE = "true"
} else {
echo "No patch file, skip stashing and publishing"
env.PUBLISH_WEBSITE = "false"
}
}
}
}
stage('publish hbase website') {
agent {
node {
label 'git-websites'
}
}
when {
expression {
return env.PUBLISH_WEBSITE == 'true'
}
}
steps {
unstash 'patch'
sh '''#!/bin/bash -e
# wipe out stall repo
rm -rf hbase-site
git clone --depth 1 --branch asf-site https://gitbox.apache.org/repos/asf/hbase-site.git
patch=$(ls -1 *.patch | head -n 1)
cd hbase-site;
echo "applying ${patch}"
git am ../${patch}
echo "Publishing changes to remote repo..."
if git push origin asf-site; then
echo "changes pushed."
else
echo "Failed to push to asf-site. Website not updated."
exit 1
fi
echo "Sending empty commit to work around INFRA-10751."
git commit --allow-empty -m "INFRA-10751 Empty commit"
# Push the empty commit
if git push origin asf-site; then
echo "empty commit pushed."
else
echo "Failed to push the empty commit to asf-site. Website may not update. Manually push an empty commit to fix this. (See INFRA-10751)"
exit 1
fi
echo "Pushed the changes to branch asf-site. Refresh http://hbase.apache.org/ to see the changes within a few minutes."
'''
}
}
}
post {
always {
// Has to be relative to WORKSPACE.
archiveArtifacts artifacts: '*.patch.zip,hbase-*.txt'
}
failure {
mail to: 'dev@hbase.apache.org', replyTo: 'dev@hbase.apache.org', subject: "Failure: HBase Generate Website", body: """
Build status: ${currentBuild.currentResult}
The HBase website has not been updated to incorporate recent HBase changes.
See ${env.BUILD_URL}console
"""
}
cleanup {
deleteDir()
}
}
}