Chore: Update gerrit-review-action to latest v0.8
[releng/builder.git] / jjb / check-poms.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2015 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 # Contributors:
12 #   Thanh Ha (The Linux Foundation) - Initial implementation
13 ##############################################################################
14
15 # Clear workspace
16 rm -rf -- "${WORKSPACE:?}"/*
17
18 # Create python script to parse json
19 cat > "${WORKSPACE}/parse_json.py" << EOF
20 import json
21 import sys
22
23 obj=json.load(sys.stdin)
24 for key in obj.keys():
25     print(key)
26
27 EOF
28
29 # Clone all ODL projects
30 curl -s --header "Accept: application/json" \
31     https://git.opendaylight.org/gerrit/projects/ | \
32     tail -n +2 > "${WORKSPACE}/projects.json"
33 for p in $(python "${WORKSPACE}/parse_json.py" < "${WORKSPACE}/projects.json")
34 do
35     # Ignore non-projects and archived projects
36     if [ "$p" == "All-Users" ] || \
37        [ "$p" == "affinity" ] || \
38        [ "$p" == "integration" ] || \
39        [ "$p" == "net-virt-platform" ] || \
40        [ "$p" == "opendove" ] || \
41        [ "$p" == "plugin2oc" ] || \
42        # Also ignore projects known to deploy to non-ODL repositories
43        [ "$p" == "yangide" ]
44     then
45         continue
46     fi
47     mkdir -p "$(dirname "$p")"
48     git clone "https://git.opendaylight.org/gerrit/$p.git" "$p"
49 done
50
51 # Check pom.xml for <repositories> and <pluginRepositories>
52 FILE=repos.txt
53
54 find . -name pom.xml -print0 | xargs -0 grep -i '<repositories>\|<pluginRepositories>' > "$FILE"
55 [[ $(tr -d "\\r\\n" < $FILE|wc -c) -eq 0 ]] && rm $FILE
56
57 if [ -a $FILE ]
58 then
59     cat $FILE
60     echo "[ERROR] Repos with <repositories> and/or <pluginRepositories> sections found!"
61     exit 1
62 fi