Add integration scripts from OPEN-O
[integration.git] / autorelease / scripts / generate-jjbs / gen-job-lists.sh
1 #!/bin/bash
2 #
3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 # autorelease root dir
19 ROOT=`git rev-parse --show-toplevel`/autorelease
20
21 BUILD_DIR=$ROOT/build
22 JJB_DIR=$BUILD_DIR/ci-management/jjb
23
24 cd $BUILD_DIR
25
26 source $ROOT/scripts/generate-jjbs/workarounds.sh
27
28
29 TMPDIR=`mktemp -d`
30 echo $TMPDIR
31
32 mkdir -p $TMPDIR/merge-jobs
33 find . -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort | while read repo; do
34     project=${repo}
35     OUTFILE=$TMPDIR/merge-jobs/${repo}.txt
36  
37     has_subprojects=0
38     for r in "${SPLIT_REPOS[@]}"; do
39         if [ "$repo" = "$r" ]; then
40             has_subprojects=1
41         fi
42     done
43
44     if [ $has_subprojects -eq 1 ]; then
45         poms=`find $repo -mindepth 1 -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
46     else
47         poms=`find $repo -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
48         if [ "$poms" != "/pom.xml" ]; then
49             has_subprojects=1
50         fi
51     fi
52     
53     
54     if [ $has_subprojects -eq 0 ]; then
55         echo ${repo}-master-merge-java > $OUTFILE
56     elif [ ! -z "$poms" ]; then
57         for pom in $poms; do
58             pompath=${pom%/pom.xml}
59             subproject=${pompath////-} # replace slash with dash
60             echo ${repo}-master-${subproject}-merge-java >> $OUTFILE
61         done
62     fi
63 done
64