| 1 |
// The documentation link checker build will build the Markdown documentation in |
| 2 |
// doc/, and ensures that all of the links contained in the documentation are |
| 3 |
// valid. |
| 4 |
// |
| 5 |
// Note that a cache is maintained on Jenkins to avoid checking the same links |
| 6 |
// over and over again. |
| 7 |
pipeline |
| 8 |
{ |
| 9 |
// Run inside of the custom Docker image for style checking. |
| 10 |
// Every docker agent has a 'link_cache/' directory in its Jenkins workspace |
| 11 |
// for this job. |
| 12 |
agent |
| 13 |
{ |
| 14 |
docker |
| 15 |
{ |
| 16 |
image 'mlpack/jenkins-mlpack-docbuild:latest' |
| 17 |
label 'doc-check' |
| 18 |
alwaysPull true |
| 19 |
args '-v /home/jenkins/link_cache/:/opt/link_cache/' |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
options |
| 24 |
{ |
| 25 |
// Only allow one build at a time of this job. |
| 26 |
disableConcurrentBuilds(abortPrevious: true) |
| 27 |
|
| 28 |
// We will do checkout manually. |
| 29 |
skipDefaultCheckout() |
| 30 |
} |
| 31 |
|
| 32 |
stages |
| 33 |
{ |
| 34 |
// Check out the repository and start the check. |
| 35 |
stage('Set up workspace') |
| 36 |
{ |
| 37 |
steps |
| 38 |
{ |
| 39 |
cleanWs(deleteDirs: true, |
| 40 |
disableDeferredWipeout: true, |
| 41 |
notFailBuild: true) |
| 42 |
checkout scm |
| 43 |
|
| 44 |
script |
| 45 |
{ |
| 46 |
u = load '.jenkins/utils.groovy' |
| 47 |
u.startCheck('Documentation link check', 'Setting up workspace...') |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
// Actually run the check. |
| 53 |
stage('Build documentation and check links') |
| 54 |
{ |
| 55 |
steps |
| 56 |
{ |
| 57 |
script { u.updateCheckStatus('Checking documentation links...') } |
| 58 |
|
| 59 |
sh ''' |
| 60 |
# Set $HOME because the Docker container may be running with a |
| 61 |
# different uid. Note that the container has /workspace/ as the |
| 62 |
# working directory; we'll just reuse that as $HOME. |
| 63 |
export HOME=/workspace/ |
| 64 |
|
| 65 |
# Print the size of the link cache. |
| 66 |
if [ ! -f /opt/link_cache/link_cache.db ]; |
| 67 |
then |
| 68 |
echo "Link cache does not exist!"; |
| 69 |
else |
| 70 |
echo "Link cache current size:"; |
| 71 |
ls -lh /opt/link_cache/link_cache.db; |
| 72 |
fi |
| 73 |
|
| 74 |
# Skip the check if the documentation build script doesn't exist. |
| 75 |
if [ ! -f scripts/build-docs.sh ]; |
| 76 |
then |
| 77 |
exit 0; |
| 78 |
fi |
| 79 |
|
| 80 |
# This will fail if there are any issues converting the Markdown to |
| 81 |
# kramdown, or if there is a linting or link-checking failure. |
| 82 |
LINK_CACHE_FILE=/opt/link_cache/link_cache.db ./scripts/build-docs.sh; |
| 83 |
build_doc_out=$?; |
| 84 |
if [ $build_doc_out -ne 0 ]; |
| 85 |
then |
| 86 |
echo "build-docs.sh failed!"; |
| 87 |
exit 1; |
| 88 |
fi |
| 89 |
''' |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
post |
| 95 |
{ |
| 96 |
success { script { u.finishCheck('No HTML issues found.', true) } } |
| 97 |
failure { script { u.finishCheck('Problems found in HTML.', false) } } |
| 98 |
|
| 99 |
always |
| 100 |
{ |
| 101 |
// Publish the generated HTML. |
| 102 |
publishHTML([ |
| 103 |
allowMissing: false, |
| 104 |
alwaysLinkToLastBuild: false, |
| 105 |
keepAll: true, |
| 106 |
reportDir: 'doc/html/', |
| 107 |
reportFiles: 'index.html', |
| 108 |
reportName: 'Build documentation']); |
| 109 |
|
| 110 |
// Clean the workspace. |
| 111 |
cleanWs(cleanWhenNotBuilt: true, |
| 112 |
deleteDirs: true, |
| 113 |
disableDeferredWipeout: true, |
| 114 |
notFailBuild: true); |
| 115 |
} |
| 116 |
} |
| 117 |
} |