Use double quotes instead of single quotes
[releng/builder.git] / jjb / autorelease / update-validate-autorelease-projects.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 - 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
12 YAML_FILE="${WORKSPACE}/jjb/autorelease/validate-autorelease-${STREAM}.yaml"
13 BRANCH="stable/${STREAM}"
14
15 # The current development release will not have a stable branch defined so if
16 # branch does not exist assume master
17 url="https://git.opendaylight.org/gerrit/projects/releng%2Fautorelease/branches/"
18 resp=$(curl -s -w "\\n\\n%{http_code}" --globoff -H "Content-Type:application/json" "$url")
19 if [[ ! "$resp" =~ $BRANCH ]]; then
20     BRANCH="master"
21 fi
22
23 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"
24 # Allow word splitting as we only expect modules to appear
25 # shellcheck disable=2207
26 modules=($(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml))
27
28 cat > "$YAML_FILE" << EOF
29 ---
30 # Autogenerated by autorelease autorelease-update-validate-autorelease-jobs-{stream} Jenkins job
31 - project:
32     name: autorelease-validate-${STREAM}
33     jobs:
34       - "{project-name}-validate-autorelease-{stream}"
35     stream: ${STREAM}
36     branch: ${BRANCH}
37     project-name:
38 EOF
39
40 for module in "${modules[@]}"; do
41     echo "Include $module"
42     echo "      - ${module//\//-}:" >> "$YAML_FILE"
43     echo "          project: $module" >> "$YAML_FILE"
44 done
45
46 git add "${YAML_FILE}"