Fix hardware_id
[ci-management.git] / jjb / scripts / csit / docs.sh
1 #!/bin/bash
2
3 # Copyright (c) 2020 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 set -xe -o pipefail
17
18 [ "$DOCS_REPO_URL" ] || DOCS_REPO_URL="https://nexus.fd.io/content/sites/site"
19 [ "$PROJECT_PATH" ] || PROJECT_PATH=io/fd/csit
20 [ "$DOC_DIR" ] || DOC_DIR=resources/tools/doc_gen
21 [ "$BUILD_DIR" ] || BUILD_DIR=${DOC_DIR}/_build
22 [ "$SITE_DIR" ] || SITE_DIR=build-root/docs/deploy-site
23 [ "$RESOURCES_DIR" ] || RESOURCES_DIR=${SITE_DIR}/src/site/resources/doc
24 [ "$MVN" ] || MVN="/opt/apache/maven/bin/mvn"
25
26 cd ${DOC_DIR}
27 chmod +x ./run_doc.sh
28 ./run_doc.sh ${GERRIT_BRANCH}
29
30 retval=$?
31 if [ ${retval} -ne "0" ]; then
32   echo "Documentation generation failed!"
33 exit ${retval}
34 fi
35
36 if [[ ${JOB_NAME} == *merge* ]]; then
37
38   cd ${WORKSPACE}
39
40   mkdir -p ${RESOURCES_DIR}
41   mv -f ${BUILD_DIR}/* ${RESOURCES_DIR}
42   cd ${SITE_DIR}
43
44   cat > pom.xml << EOF
45   <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">
46     <modelVersion>4.0.0</modelVersion>
47     <groupId>io.fd.csit</groupId>
48     <artifactId>docs</artifactId>
49     <version>1.0.0</version>
50     <packaging>pom</packaging>
51     <properties>
52       <generateReports>false</generateReports>
53     </properties>
54     <build>
55       <extensions>
56         <extension>
57           <groupId>org.apache.maven.wagon</groupId>
58           <artifactId>wagon-webdav-jackrabbit</artifactId>
59           <version>2.10</version>
60         </extension>
61       </extensions>
62     </build>
63     <distributionManagement>
64       <site>
65         <id>fdio-site</id>
66         <url>dav:${DOCS_REPO_URL}/${PROJECT_PATH}/${GERRIT_BRANCH}</url>
67       </site>
68     </distributionManagement>
69   </project>
70 EOF
71
72   ${MVN} site:site site:deploy -gs "${GLOBAL_SETTINGS_FILE}" -s "${SETTINGS_FILE}" -T 4C
73
74   cd -
75
76 fi