Automate validate-autorelease job management
[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 --no-verbose -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 --no-verbose -O /tmp/pom.xml "https://git.opendaylight.org/gerrit/gitweb?p=releng/autorelease.git;a=blob_plain;f=pom.xml;hb=$GERRIT_BRANCH"
23 modules=($(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml))
24
25 cat > "$YAML_FILE" << EOF
26 ---
27 # Autogenerated by autorelease autorelease-update-validate-autorelease-jobs-{stream} Jenkins job
28 - project:
29     name: autorelease-validate-${STREAM}
30     jobs:
31       - '{project-name}-validate-autorelease-{stream}'
32     stream: ${STREAM}
33     branch: ${BRANCH}
34     project-name:
35 EOF
36
37 for module in "${modules[@]}"; do
38     echo "Include $module"
39     echo "      - $module:" >> "$YAML_FILE"
40     echo "          project: $module" >> "$YAML_FILE"
41 done
42
43 git add "${YAML_FILE}"