forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-18548 Move sources of website gen and check jobs into source co…
…ntrol
- Loading branch information
Misty Stanley-Jones
committed
Aug 10, 2017
1 parent
ded0842
commit 6114824
Showing
8 changed files
with
216 additions
and
17 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# This script is designed to run as a Jenkins job, such as at | ||
# https://builds.apache.org/view/All/job/HBase%20Website%20Link%20Checker/ | ||
# | ||
# It generates artifacts which the Jenkins job then can mail out and/or archive. | ||
# | ||
# We download a specific version of linklint because the original has bugs and | ||
# is not well maintained. | ||
# | ||
# See http://www.linklint.org/doc/inputs.html for linklint options | ||
|
||
# Clean up the workspace | ||
rm -rf *.zip > /dev/null | ||
rm -rf linklint > /dev/null | ||
rm -Rf link_report | ||
|
||
# This version of linklint fixes some bugs in the now-unmaintained 2.3.5 version | ||
wget http://ingo-karkat.de/downloads/tools/linklint/linklint-2.3.5_ingo_020.zip | ||
unzip linklint-2.3.5_ingo_020.zip | ||
chmod +x linklint/linklint.pl | ||
|
||
# Run the checker | ||
echo "Checking http://hbase.apache.org and saving report to link_report/" | ||
echo "Excluding /testapidocs/ because some tests use private classes not published in /apidocs/." | ||
# Check internal structure | ||
linklint/linklint.pl -http \ | ||
-host hbase.apache.org \ | ||
/@ \ | ||
-skip /testapidocs/@ \ | ||
-skip /testdevapidocs/@ \ | ||
-net \ | ||
-redirect \ | ||
-no_query_string \ | ||
-htmlonly \ | ||
-timeout 30 \ | ||
-delay 1 \ | ||
-limit 100000 \ | ||
-doc link_report | ||
|
||
# Detect whether we had errors and act accordingly | ||
if ! grep -q 'ERROR' link_report/index.html; then | ||
echo "Errors found. Sending email." | ||
exit 1 | ||
else | ||
echo "No errors found. Warnings might be present." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#!/bin/bash | ||
|
||
# This script is meant to run as part of a Jenkins job such as | ||
# https://builds.apache.org/job/hbase_generate_website/ | ||
# | ||
# It needs to be built on a Jenkins server with the label git-websites | ||
# | ||
# It expects to have the hbase repo cloned to the directory hbase | ||
# | ||
# If there is a build error, the Jenkins job is configured to send an email | ||
|
||
LOCAL_REPO=${WORKSPACE}/.m2/repo | ||
# Nuke the local maven repo each time, to start with a known environment | ||
rm -Rf "${LOCAL_REPO}" | ||
mkdir -p "${LOCAL_REPO}" | ||
|
||
# Clean any leftover files in case we are reusing the workspace | ||
rm -Rf -- *.patch *.patch.zip hbase/target target *.txt hbase-site | ||
|
||
# Set up the environment | ||
export JAVA_HOME=$JDK_1_8_LATEST__HOME | ||
export PATH=$JAVA_HOME/bin:$MAVEN_3_3_3_HOME/bin:$PATH | ||
export MAVEN_OPTS="-XX:MaxPermSize=256m -Dmaven.repo.local=${LOCAL_REPO}" | ||
|
||
# Verify the Maven version | ||
mvn -version | ||
|
||
# Save and print the SHA we are building | ||
CURRENT_HBASE_COMMIT="$(git log --pretty=format:%H -n1)" | ||
echo "Current HBase commit: $CURRENT_HBASE_COMMIT" | ||
|
||
# Clone the hbase-site repo manually so it doesn't trigger spurious | ||
# commits in Jenkins. | ||
git clone --depth 1 --branch asf-site https://git-wip-us.apache.org/repos/asf/hbase-site.git | ||
|
||
# Figure out the last commit we built the site from, and bail if the build | ||
# still represents the SHA of HBase master | ||
cd "${WORKSPACE}/hbase-site" || exit -1 | ||
git log --pretty=%s | grep ${CURRENT_HBASE_COMMIT} | ||
PUSHED=$? | ||
echo "PUSHED is $PUSHED" | ||
|
||
if [ $PUSHED -eq 0 ]; then | ||
echo "$CURRENT_HBASE_COMMIT is already mentioned in the hbase-site commit log. Not building." | ||
exit 0 | ||
else | ||
echo "$CURRENT_HBASE_COMMIT is not yet mentioned in the hbase-site commit log. Assuming we don't have it yet. $PUSHED" | ||
fi | ||
|
||
# Go to the hbase directory so we can build the site | ||
cd "${WORKSPACE}/hbase" || exit -1 | ||
|
||
# This will only be set for builds that are triggered by SCM change, not manual builds | ||
if [ "$CHANGE_ID" ]; then | ||
echo -n " ($CHANGE_ID - $CHANGE_TITLE)" | ||
fi | ||
|
||
# Build and install HBase, then build the site | ||
echo "Building HBase" | ||
mvn \ | ||
-DskipTests \ | ||
-Dmaven.javadoc.skip=true \ | ||
--batch-mode \ | ||
-Dcheckstyle.skip=true \ | ||
-Dfindbugs.skip=true \ | ||
--log-file="${WORKSPACE}/hbase-build-log-${CURRENT_HBASE_COMMIT}.txt" \ | ||
clean install \ | ||
&& mvn clean site \ | ||
--batch-mode \ | ||
-DskipTests \ | ||
--log-file="${WORKSPACE}/hbase-install-log-${CURRENT_HBASE_COMMIT}.txt" | ||
|
||
status=$? | ||
if [ $status -ne 0 ]; then | ||
echo "Failure: mvn clean site" | ||
exit $status | ||
fi | ||
|
||
# Stage the site | ||
echo "Staging HBase site" | ||
mvn \ | ||
--batch-mode \ | ||
--log-file="${WORKSPACE}/hbase-stage-log-${CURRENT_HBASE_COMMIT}.txt" \ | ||
site:stage | ||
status=$? | ||
if [ $status -ne 0 ] || [ ! -d target/staging ]; then | ||
echo "Failure: mvn site:stage" | ||
exit $status | ||
fi | ||
|
||
# Get ready to update the hbase-site repo with the new artifacts | ||
cd "${WORKSPACE}/hbase-site" || exit -1 | ||
|
||
#Remove previously-generated files | ||
FILES_TO_REMOVE=("hbase-*" | ||
"apidocs" | ||
"devapidocs" | ||
"testapidocs" | ||
"testdevapidocs" | ||
"xref" | ||
"xref-test" | ||
"*book*" | ||
"*.html" | ||
"*.pdf*" | ||
"css" | ||
"js" | ||
"images") | ||
|
||
for FILE in "${FILES_TO_REMOVE[@]}"; do | ||
echo "Removing ${WORKSPACE}/hbase-site/$FILE" | ||
rm -Rf "${FILE}" | ||
done | ||
|
||
# Copy in the newly-built artifacts | ||
cp -au "${WORKSPACE}"/hbase/target/staging/* . | ||
|
||
# If the index.html is missing, bail because this is serious | ||
if [ ! -f index.html ]; then | ||
echo "The index.html is missing. Aborting." | ||
exit 1 | ||
else | ||
# Add all the changes | ||
echo "Adding all the files we know about" | ||
git add . | ||
# Create the commit message and commit the changes | ||
WEBSITE_COMMIT_MSG="Published site at $CURRENT_HBASE_COMMIT." | ||
echo "WEBSITE_COMMIT_MSG: $WEBSITE_COMMIT_MSG" | ||
git commit -m "${WEBSITE_COMMIT_MSG}" -a | ||
# Dump a little report | ||
echo "This commit changed these files (excluding Modified files):" | ||
git diff --name-status --diff-filter=ADCRTXUB origin/asf-site | ||
# Create a patch, which Jenkins can save as an artifact and can be examined for debugging | ||
git format-patch --stdout origin/asf-site > "${WORKSPACE}/${CURRENT_HBASE_COMMIT}.patch" | ||
echo "Change set saved to patch ${WORKSPACE}/${CURRENT_HBASE_COMMIT}.patch" | ||
# Push the real commit | ||
git push origin asf-site || (echo "Failed to push to asf-site. Website not updated." && exit -1) | ||
# Create an empty commit to work around INFRA-10751 | ||
git commit --allow-empty -m "INFRA-10751 Empty commit" | ||
# Push the empty commit | ||
git push origin asf-site || (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) | ||
echo "Pushed the changes to branch asf-site. Refresh http://hbase.apache.org/ to see the changes within a few minutes." | ||
git fetch origin | ||
git reset --hard origin/asf-site | ||
|
||
# Zip up the patch so Jenkins can save it | ||
cd "${WORKSPACE}" || exit -1 | ||
zip website.patch.zip "${CURRENT_HBASE_COMMIT}.patch" | ||
fi | ||
|
||
#echo "Dumping current environment:" | ||
#env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters