Merge "Fix debian-9 docker image builder"
[ci-management.git] / jjb / scripts / vpp / sphinx-docs.sh
1 #!/bin/bash
2
3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "---> jjb/scripts/vpp/sphinx-docs.sh"
17
18 set -euxo pipefail
19
20 line="*************************************************************************"
21 # Don't build anything if this is a merge job being run when
22 # the git HEAD id is not the same as the Gerrit New Revision id.
23 if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
24        [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
25     echo -e "\n$line\nSkipping sphinx docs build. A newer patch has been merged.\n$line\n"
26     exit 0
27 fi
28
29 DOCS_REPO_URL=${DOCS_REPO_URL:-"https://nexus.fd.io/content/sites/site"}
30 PROJECT_PATH=${PROJECT_PATH:-"io/fd/vpp"}
31 DOC_FILE=${DOC_FILE:-"vpp.docs.zip"}
32 DOC_DIR=${DOC_DIR:-"./docs/_build/html"}
33 SITE_DIR=${SITE_DIR:-"build-root/docs/deploy-site"}
34 RESOURCES_DIR=${RESOURCES_DIR:-"${SITE_DIR}/src/site/resources"}
35 MVN=${MVN:-"/opt/apache/maven/bin/mvn"}
36 VERSION=${VERSION:-"$(./build-root/scripts/version rpm-version)"}
37
38 make docs-venv
39 CONFIRM=-y FORCE=--force-yes make docs
40
41 if [[ ${JOB_NAME} == *merge* ]]; then
42   mkdir -p $(dirname ${RESOURCES_DIR})
43   mv -f ${DOC_DIR} ${RESOURCES_DIR}
44   cd ${SITE_DIR}
45   cat > pom.xml << EOF
46   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
47     <modelVersion>4.0.0</modelVersion>
48     <groupId>io.fd.vpp</groupId>
49     <artifactId>docs</artifactId>
50     <version>1.0.0</version>
51     <packaging>pom</packaging>
52
53     <properties>
54       <generateReports>false</generateReports>
55     </properties>
56
57     <build>
58       <extensions>
59         <extension>
60           <groupId>org.apache.maven.wagon</groupId>
61            <artifactId>wagon-webdav-jackrabbit</artifactId>
62            <version>2.10</version>
63         </extension>
64       </extensions>
65     </build>
66     <distributionManagement>
67       <site>
68         <id>fdio-site</id>
69         <url>dav:${DOCS_REPO_URL}/${PROJECT_PATH}/v${VERSION}</url>
70       </site>
71     </distributionManagement>
72   </project>
73 EOF
74   ${MVN} -B site:site site:deploy -gs "${GLOBAL_SETTINGS_FILE}" -s "${SETTINGS_FILE}" -T 4C
75   cd -
76 fi