blob: 9432cee549b6388f919aeb409e65fb63669594d9 [file] [log] [blame]
Gary Wud04e4402017-07-28 12:26:54 -07001#!/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
19ROOT=`git rev-parse --show-toplevel`/autorelease
20
21BUILD_DIR=$ROOT/build
22JJB_DIR=$BUILD_DIR/ci-management/jjb
23
24cd $BUILD_DIR
25
26source $ROOT/scripts/generate-jjbs/workarounds.sh
27
28
29find . -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort | while read repo; do
30 project=${repo}
31
32 toxs=`find $repo -type d -exec test -e "{}/tox.ini" ';' -prune -printf "%P/tox.ini\n" | sort`
33
34 in_sun_branch=`git show sun:autorelease/all-projects.txt | grep -x ${repo}`
35
36 mkdir -p $JJB_DIR/$repo
37
38 if [ ! -z "$toxs" ]; then
39 rm -f $JJB_DIR/$repo/${repo}-python.yaml
40
41 project=${repo}-java
42 echo $repo/${repo}-python.yaml
43
44 cat > $JJB_DIR/$repo/${repo}-python.yaml <<EOF
45---
46- project:
47 name: ${repo}-python
48 project: '${repo}'
49 stream:
50 - 'master':
51 branch: 'master'
52EOF
53 if [ $in_sun_branch ]; then
54 cat >> $JJB_DIR/$repo/${repo}-python.yaml <<EOF
55 - 'sun':
56 branch: 'sun'
57EOF
58 fi
59 cat >> $JJB_DIR/$repo/${repo}-python.yaml <<EOF
60 mvn-settings: '${repo}-settings'
61 build-node: 'centos7-redis-2c-1g'
62 subproject:
63EOF
64 for tox in $toxs; do
65 toxpath=${tox%/tox.ini}
66
67 if [ "$toxpath" == "" ]; then
68 subproject="root"
69 pathparam="."
70 pattern="**"
71 else
72 subproject=${toxpath////-} # replace slash with dash
73 pathparam=$toxpath
74 pattern="$toxpath/**"
75
76 # do special subproject names
77 for SUB in "${SUBPROJECT_MAP[@]}"; do
78 if [ "${SUB%:*}" = "$repo/$toxpath" ]; then
79 subproject=${SUB#*:}
80 fi
81 done
82 fi
83
84 cat >> $JJB_DIR/$repo/${repo}-python.yaml <<EOF
85 - '${subproject}':
86 path: '${pathparam}'
87 pattern: '${pattern}'
88EOF
89 done
90 cat >> $JJB_DIR/$repo/${repo}-python.yaml <<EOF
91 jobs:
92 - '{project}-{stream}-{subproject}-verify-python'
93EOF
94 fi
95
96
97
98
99 has_subprojects=0
100 for r in "${SPLIT_REPOS[@]}"; do
101 if [ "$repo" = "$r" ]; then
102 has_subprojects=1
103 fi
104 done
105
106 if [ $has_subprojects -eq 1 ]; then
107 poms=`find $repo -mindepth 1 -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
108 else
109 poms=`find $repo -type d -exec test -e "{}/pom.xml" ';' -prune -printf "%P/pom.xml\n" | sort`
110 if [ "$poms" != "/pom.xml" ]; then
111 has_subprojects=1
112 fi
113 fi
114
115
116 if [ ! -z "$poms" ]; then
117 rm -f $JJB_DIR/$repo/${repo}.yaml
118 rm -f $JJB_DIR/$repo/${repo}-java.yaml
119 echo $repo/${project}.yaml
120 fi
121
122 if [ $has_subprojects -eq 0 ]; then
123 # root pom.xml found
124 cat > $JJB_DIR/$repo/${project}.yaml <<EOF
125---
126- project:
127 name: ${project}
128 jobs:
129 - '{project}-{stream}-verify-java'
130 - '{project}-{stream}-merge-java'
131
132 project: '${repo}'
133 stream:
134 - 'master':
135 branch: 'master'
136EOF
137 if [ $in_sun_branch ]; then
138 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
139 - 'sun':
140 branch: 'sun'
141EOF
142 fi
143 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
144 mvn-settings: '${repo}-settings'
145EOF
146 elif [ ! -z "$poms" ]; then
147 cat > $JJB_DIR/$repo/${project}.yaml <<EOF
148---
149- project:
150 name: ${project}
151 project: '${repo}'
152 stream:
153 - 'master':
154 branch: 'master'
155EOF
156 if [ $in_sun_branch ]; then
157 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
158 - 'sun':
159 branch: 'sun'
160EOF
161 fi
162 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
163 mvn-settings: '${repo}-settings'
164 subproject:
165EOF
166
167 for pom in $poms; do
168 pompath=${pom%/pom.xml}
169 subproject=${pompath////-} # replace slash with dash
170 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
171 - '${subproject}':
172 pom: '${pom}'
173 pattern: '${pompath}/**'
174EOF
175 done
176
177 if [ -e $BUILD_DIR/$repo/pom.xml ]; then
178 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
179 - 'root':
180 pom: 'pom.xml'
181 pattern: '*'
182EOF
183 fi
184
185 cat >> $JJB_DIR/$repo/${project}.yaml <<EOF
186 jobs:
187 - '{project}-{stream}-{subproject}-verify-java'
188 - '{project}-{stream}-{subproject}-merge-java'
189EOF
190 fi
191done