Update Ansible playbooks to new names
[releng/builder.git] / jjb / autorelease / update-validate-autorelease-projects.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 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 wget -nv -O /tmp/ar-branches.json https://git.opendaylight.org/gerrit/projects/releng%2Fautorelease/branches/
18 if ! grep "$BRANCH" /tmp/ar-branches.json; then
19     BRANCH=master
20 fi
21
22 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"
23 # Allow word splitting as we only expect modules to appear
24 # shellcheck disable=2207
25 modules=($(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml))
26
27 cat > "$YAML_FILE" << EOF
28 ---
29 # Autogenerated by autorelease autorelease-update-validate-autorelease-jobs-{stream} Jenkins job
30 - project:
31     name: autorelease-validate-${STREAM}
32     jobs:
33       - '{project-name}-validate-autorelease-{stream}'
34     stream: ${STREAM}
35     branch: ${BRANCH}
36     project-name:
37 EOF
38
39 for module in "${modules[@]}"; do
40     echo "Include $module"
41     echo "      - ${module//\//-}:" >> "$YAML_FILE"
42     echo "          project: $module" >> "$YAML_FILE"
43 done
44
45 git add "${YAML_FILE}"