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