Skip to content

Commit 87428ff

Browse files
authored
boostorg/website-v2-docs (#16)
1 parent 49242f7 commit 87428ff

File tree

2 files changed

+335
-0
lines changed

2 files changed

+335
-0
lines changed

jenkinsfiles/website_v2_docs_1

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
pipeline {
2+
3+
// agent {
4+
// node {
5+
// label 'jenkinspool1'
6+
// }
7+
// }
8+
9+
agent {
10+
docker {
11+
image 'cppalliance/boost_superproject_build:24.04-v2'
12+
// label 'jenkinspool1'
13+
}
14+
}
15+
16+
stages {
17+
stage('Preclean Workspace') {
18+
steps {
19+
sh """#!/bin/bash
20+
set -xe
21+
rm -rf * .*
22+
"""
23+
checkout scm
24+
}
25+
}
26+
27+
stage('Set Variables') {
28+
steps {
29+
sh '''#!/bin/bash -xe
30+
echo "" > jenkinsjobinfo.sh
31+
chmod 777 jenkinsjobinfo.sh
32+
REPONAME=$(basename -s .git "$(git config --get remote.origin.url)")
33+
# REPONAME=$(basename `git rev-parse --show-toplevel`)
34+
# If this jenkinsfile will be used for multiple repos then it should use the general form of DNSREPONAME:
35+
# DNSREPONAME=$(echo $REPONAME | tr '_' '-')
36+
# However at the moment it's only used by website-v2-docs. For the time being, the customization may be placed here:
37+
DNSREPONAME="site-docs"
38+
ORGANIZATION=$(basename $(dirname "${GIT_URL}"))
39+
if [[ "${GIT_URL}" =~ sdarwin ]]; then
40+
# testing environment
41+
echo "export JENKINS_CI_REPO=sdarwin/jenkins-ci" >> jenkinsjobinfo.sh
42+
echo "export JENKINS_CI_REPO_BRANCH=testing" >> jenkinsjobinfo.sh
43+
else
44+
# standard
45+
echo "export JENKINS_CI_REPO=cppalliance/jenkins-ci" >> jenkinsjobinfo.sh
46+
echo "export JENKINS_CI_REPO_BRANCH=master" >> jenkinsjobinfo.sh
47+
fi
48+
echo "export PRTEST=prtest2" >> jenkinsjobinfo.sh
49+
echo "export REPONAME=${REPONAME}" >> jenkinsjobinfo.sh
50+
echo "export DNSREPONAME=${DNSREPONAME}" >> jenkinsjobinfo.sh
51+
echo "export ORGANIZATION=${ORGANIZATION}" >> jenkinsjobinfo.sh
52+
'''
53+
}
54+
}
55+
56+
stage('Diagnostics') {
57+
steps {
58+
sh '''#!/bin/bash
59+
set -x
60+
# not set -e. errors may occur in diagnostics
61+
cat jenkinsjobinfo.sh
62+
. jenkinsjobinfo.sh
63+
ls -al
64+
cat /etc/os-release
65+
pwd
66+
env
67+
whoami
68+
touch $(date "+%A-%B-%d-%T-%y")
69+
mount | grep ^/dev/ | grep -v /etc | awk '{print \$3}'
70+
git branch
71+
git branch -avv
72+
true
73+
'''
74+
}
75+
}
76+
77+
stage('Prebuild script') {
78+
when {
79+
anyOf{
80+
branch 'develop'
81+
branch 'master'
82+
expression { env.CHANGE_ID != null }
83+
}
84+
}
85+
steps {
86+
sh '''#!/bin/bash
87+
set -xe
88+
. jenkinsjobinfo.sh
89+
curl -f -o jenkins_prebuild_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_prebuild.sh || true
90+
if [ -f jenkins_prebuild_script.sh ]; then
91+
chmod 755 jenkins_prebuild_script.sh
92+
./jenkins_prebuild_script.sh
93+
fi
94+
'''
95+
}
96+
}
97+
98+
// To skip this step, and actually all steps, adjust the job's Filter regex in the Jenkins UI
99+
// (develop|master|PR-.*) will build all branches
100+
// (PR-.*) will build pull requests. Etc.
101+
stage('Build docs') {
102+
when {
103+
anyOf{
104+
branch 'develop'
105+
branch 'master'
106+
expression { env.CHANGE_ID != null }
107+
}
108+
}
109+
110+
steps {
111+
sh '''#!/bin/bash
112+
set -xe
113+
. jenkinsjobinfo.sh
114+
export pythonvirtenvpath=/opt/venvboostdocs
115+
if [ -f ${pythonvirtenvpath}/bin/activate ]; then
116+
source ${pythonvirtenvpath}/bin/activate
117+
fi
118+
119+
# Is there a custom build script? Often not. But let's check:
120+
121+
curl -f -o jenkins_build_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_build.sh || true
122+
if [ -f jenkins_build_script.sh ]; then
123+
chmod 755 jenkins_build_script.sh
124+
./jenkins_build_script.sh
125+
exit 0
126+
fi
127+
128+
# Otherwise, proceed using standard build steps:
129+
130+
export pythonvirtenvpath=/opt/venvboostdocs
131+
if [ -f ${pythonvirtenvpath}/bin/activate ]; then
132+
source ${pythonvirtenvpath}/bin/activate
133+
fi
134+
135+
echo "env"
136+
env
137+
138+
echo "pwd"
139+
pwd
140+
141+
echo "home is $HOME"
142+
143+
echo "ls -al HOME"
144+
ls -al $HOME
145+
146+
echo "ls ~/"
147+
ls -al ~/
148+
149+
150+
mkdir -p ~/.nvm_${REPONAME}_antora
151+
export NODE_VERSION=18.18.1
152+
# The container has a pre-installed nodejs. Overwrite those again.
153+
export NVM_BIN="$HOME/.nvm_${REPONAME}_antora/versions/node/v18.18.1/bin"
154+
export NVM_DIR=$HOME/.nvm_${REPONAME}_antora
155+
export NVM_INC=$HOME/.nvm_${REPONAME}_antora/versions/node/v18.18.1/include/node
156+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
157+
export NVM_DIR=$HOME/.nvm_${REPONAME}_antora
158+
. "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
159+
. "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
160+
. "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
161+
export PATH="$HOME/.nvm_${REPONAME}_antora/versions/node/v${NODE_VERSION}/bin/:${PATH}"
162+
node --version
163+
npm --version
164+
npm install [email protected]
165+
npm install @mermaid-js/[email protected]
166+
167+
npm ci
168+
169+
./build.sh ${CHANGE_TARGET}
170+
171+
rm build/index.html || true
172+
curl -f -o build/index.html https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_index.html
173+
cat build/index.html
174+
'''
175+
}
176+
}
177+
178+
stage('Postbuild script') {
179+
when {
180+
anyOf{
181+
branch 'develop'
182+
branch 'master'
183+
expression { env.CHANGE_ID != null }
184+
}
185+
}
186+
steps {
187+
sh '''#!/bin/bash
188+
set -xe
189+
190+
. jenkinsjobinfo.sh
191+
curl -f -o jenkins_postbuild_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_postbuild.sh || true
192+
if [ -f jenkins_postbuild_script.sh ]; then
193+
chmod 755 jenkins_postbuild_script.sh
194+
./jenkins_postbuild_script.sh
195+
fi
196+
'''
197+
}
198+
}
199+
200+
stage('Main branches: Upload to S3') {
201+
when {
202+
anyOf{
203+
branch 'develop'
204+
branch 'master'
205+
}
206+
}
207+
208+
environment {
209+
// See https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
210+
REPONAME = """${sh(
211+
returnStdout: true,
212+
script: '#!/bin/bash \n' + 'source jenkinsjobinfo.sh; echo -n "${REPONAME}"'
213+
)}"""
214+
DNSREPONAME = """${sh(
215+
returnStdout: true,
216+
script: '#!/bin/bash \n' + 'source jenkinsjobinfo.sh; echo -n "${DNSREPONAME}"'
217+
)}"""
218+
}
219+
220+
steps {
221+
222+
withAWS(region:'us-east-1', credentials: 'cppalliance-bot-aws-user') {
223+
sh '''#!/bin/bash
224+
set -xe
225+
aws s3 rm --recursive s3://cppalliance-websites/${BRANCH_NAME}.${DNSREPONAME}.cpp.al/
226+
'''
227+
s3Upload(bucket:"cppalliance-websites", path:"${BRANCH_NAME}.${DNSREPONAME}.cpp.al", workingDir: "build", includePathPattern:"**")
228+
}
229+
}
230+
}
231+
232+
233+
stage('Pull requests: Upload to S3') {
234+
when {
235+
anyOf{
236+
expression { env.CHANGE_ID != null }
237+
}
238+
}
239+
240+
environment {
241+
// See https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
242+
REPONAME = """${sh(
243+
returnStdout: true,
244+
script: '#!/bin/bash \n' + 'source jenkinsjobinfo.sh; echo -n "${REPONAME}"'
245+
)}"""
246+
DNSREPONAME = """${sh(
247+
returnStdout: true,
248+
script: '#!/bin/bash \n' + 'source jenkinsjobinfo.sh; echo -n "${DNSREPONAME}"'
249+
)}"""
250+
PRTEST = """${sh(
251+
returnStdout: true,
252+
script: '#!/bin/bash \n' + 'source jenkinsjobinfo.sh; echo -n "${PRTEST}"'
253+
)}"""
254+
255+
}
256+
257+
steps {
258+
withAWS(region:'us-east-1', credentials: 'cppalliance-bot-aws-user') {
259+
260+
sh '''#!/bin/bash
261+
set -xe
262+
aws s3 rm --recursive s3://cppalliance-previews/${DNSREPONAME}/${CHANGE_ID}/
263+
'''
264+
265+
s3Upload(bucket:"cppalliance-previews", path:"${DNSREPONAME}/${CHANGE_ID}/", workingDir: "build" , includePathPattern:"**")
266+
267+
}
268+
script {
269+
270+
commenttext = "An automated preview of the documentation is available at [https://${env.CHANGE_ID}.${env.DNSREPONAME}.${env.PRTEST}.cppalliance.org/index.html](https://${env.CHANGE_ID}.${env.DNSREPONAME}.${env.PRTEST}.cppalliance.org/index.html)"
271+
272+
pullRequest.comment(commenttext)
273+
274+
}
275+
}
276+
}
277+
278+
stage('Post Diagnostics') {
279+
steps {
280+
sh '''#!/bin/bash
281+
set -x
282+
# not set -e. errors may occur in diagnostics
283+
cat jenkinsjobinfo.sh
284+
. jenkinsjobinfo.sh
285+
ls -al
286+
cat /etc/os-release
287+
pwd
288+
env
289+
whoami
290+
touch $(date "+%A-%B-%d-%T-%y")
291+
mount | grep ^/dev/ | grep -v /etc | awk '{print \$3}'
292+
git branch
293+
git branch -avv
294+
true
295+
'''
296+
}
297+
}
298+
299+
}
300+
301+
post {
302+
always {
303+
echo 'This will always run'
304+
}
305+
success {
306+
echo 'This will run only if successful'
307+
// no email on success
308+
// mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "SUCCESS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
309+
}
310+
failure {
311+
echo 'This will run only if failure'
312+
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
313+
}
314+
unstable {
315+
echo 'This will run only if the run was marked as unstable'
316+
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "UNSTABLE STATUS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
317+
}
318+
changed {
319+
echo 'This will run only if the state of the Pipeline has changed'
320+
echo 'For example, if the Pipeline was previously failing but is now successful'
321+
// no email on changed status
322+
// mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "CHANGED STATUS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
323+
}
324+
}
325+
326+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Refresh" content="0; url='user-guide/index.html'" />
5+
</head>
6+
<body>
7+
<p>You will be redirected to user-guide/index.html soon!</p>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)