abfde5b9c66fa29e3f48571d3fe9bf091efbe96c
[releng/builder.git] / jjb / autorelease / update-autorelease-projects-views.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> update-autorelease-projects-views.sh"
12
13 VIEWS_AR_YAML_FILE="${WORKSPACE}/jjb/autorelease/view-autorelease-${STREAM}.yaml"
14 BRANCH="stable/${STREAM}"
15
16 # The current development release will not have a stable branch defined so if
17 # branch does not exist assume master
18 url="https://git.opendaylight.org/gerrit/projects/releng%2Fautorelease/branches/"
19 resp=$(curl -s -w "\\n\\n%{http_code}" --globoff -H "Content-Type:application/json" "$url")
20 if [[ ! "$resp" =~ $BRANCH ]]; then
21     BRANCH="master"
22 fi
23
24 wget -nv -O /tmp/pom.xml "https://git.opendaylight.org/gerrit/gitweb?p=releng/autorelease.git;a=blob_plain;f=pom.xml;hb=$GERRIT_BRANCH"
25
26 # handle list of projects read from the pom.xml output as multiple lines.
27 mapfile -t modules < <(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml)
28
29 cat > "$VIEWS_AR_YAML_FILE" << EOF
30 ---
31 # Autogenerated view by autorelease autorelease-update-validate-jobs-{stream} Jenkins job
32 - releng_view: &releng_autorelease_view_common_${STREAM}
33     name: releng-view-autorelease-${STREAM}
34     view-type: list
35     filter-executors: false
36     filter-queue: false
37     columns:
38       - status
39       - weather
40       - job
41       - last-success
42       - last-failure
43       - last-duration
44       - build-button
45       - jacoco
46       - find-bugs
47       - robot-list
48     recurse: false
49
50 - view:
51     name: Merge-${STREAM^}
52     description: 'List of ${STREAM^} Merge jobs for Autorelease'
53     job-name:
54 EOF
55
56 for module in "${modules[@]}"; do
57     echo "Include project:$module to autorelease view"
58     echo "      - '$module-maven-merge-${STREAM}'" >> "$VIEWS_AR_YAML_FILE"
59 done
60 echo "    <<: *releng_autorelease_view_common_${STREAM}" >> "$VIEWS_AR_YAML_FILE"
61
62 git add "${VIEWS_AR_YAML_FILE}"
63
64 mkdir -p "${WORKSPACE}/archives"
65 cp "${VIEWS_AR_YAML_FILE}" "${WORKSPACE}/archives"