summaryrefslogtreecommitdiffstats
path: root/autorelease/scripts/generate-jjbs/gen-job-lists.sh
blob: 4e12c91dc4821867783a55e16383940d1a596e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Copyright 2016-2017 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# autorelease root dir
ROOT=`git rev-parse --show-toplevel`/autorelease

BUILD_DIR=$ROOT/build
JJB_DIR=$BUILD_DIR/ci-management/jjb

cd $BUILD_DIR

source $ROOT/scripts/generate-jjbs/workarounds.sh


TMPDIR=`mktemp -d`
echo $TMPDIR

mkdir -p $TMPDIR/merge-jobs
find . -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort | while read repo; do
    project=${repo}
    OUTFILE=$TMPDIR/merge-jobs/${repo}.txt
 
    has_subprojects=0
    for r in "${SPLIT_REPOS[@]}"; do
	if [ "$repo" = "$r" ]; then
	    has_subprojects=1
	fi
    done

    if [ $has_subprojects -eq 1 ]; then
	poms=`find $repo -mindepth 1 -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
    else
	poms=`find $repo -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
	if [ "$poms" != "/pom.xml" ]; then
	    has_subprojects=1
	fi
    fi
    
    
    if [ $has_subprojects -eq 0 ]; then
	echo ${repo}-master-merge-java > $OUTFILE
    elif [ ! -z "$poms" ]; then
	for pom in $poms; do
	    pompath=${pom%/pom.xml}
	    subproject=${pompath////-} # replace slash with dash
	    echo ${repo}-master-${subproject}-merge-java >> $OUTFILE
	done
    fi
done