@@ -29,7 +29,6 @@ PARENT_BUILD_NAME=""
29
29
PARENT_BUILD_ID=" "
30
30
BUILD_NAME_PATTERN=" "
31
31
BUILD_INFO_REPO=" "
32
- LOOKBACK=" 90d"
33
32
34
33
show_help () {
35
34
echo " Usage: $0 --project <project> --parent-build-name <name> --parent-build-id <id> --build-name-pattern <pattern> [OPTIONS]" >&2
@@ -44,7 +43,6 @@ show_help() {
44
43
echo " " >&2
45
44
echo " Options:" >&2
46
45
echo " --build-info-repo <repo> Project-scoped build-info repo (default: <project>-build-info)" >&2
47
- echo " --lookback <days> Only consider builds from last N days (default: 90d)" >&2
48
46
echo " --dry-run Show what would be done without actually doing it" >&2
49
47
echo " --help, -h Show this help message" >&2
50
48
echo " " >&2
@@ -54,7 +52,6 @@ show_help() {
54
52
}
55
53
56
54
# Parse command line arguments
57
- echo " Command line: $0 $* " >&2
58
55
while [[ $# -gt 0 ]]; do
59
56
case $1 in
60
57
--project)
@@ -77,10 +74,6 @@ while [[ $# -gt 0 ]]; do
77
74
BUILD_INFO_REPO=" $2 "
78
75
shift 2
79
76
;;
80
- --lookback)
81
- LOOKBACK=" $2 "
82
- shift 2
83
- ;;
84
77
--dry-run)
85
78
DRY_RUN=" true"
86
79
shift
@@ -121,9 +114,6 @@ if [[ -z "${BUILD_INFO_REPO:-}" ]]; then
121
114
BUILD_INFO_REPO=" ${PROJECT} -build-info"
122
115
fi
123
116
124
- # === Derived ===
125
- SUFFIX_PREFIX=" ${PARENT_BUILD_NAME} -"
126
-
127
117
# Run function for dry-run support
128
118
run () {
129
119
if [[ " $DRY_RUN " == " true" ]]; then
@@ -136,9 +126,7 @@ run() {
136
126
137
127
echo " Build-info repo: $BUILD_INFO_REPO "
138
128
echo " Parent build: $PARENT_BUILD_NAME /$PARENT_BUILD_ID "
139
- echo " Suffix prefix: $SUFFIX_PREFIX "
140
129
echo " Project: $PROJECT "
141
- echo " Lookback: $LOOKBACK "
142
130
143
131
# === Construct AQL ===
144
132
# Calculate the date 90 days ago for proper AQL syntax
@@ -155,42 +143,25 @@ items.find({
155
143
}).include("path","name")
156
144
AQL
157
145
158
- # === Run query ===
146
+ # Query for build-info JSON files
159
147
RESP=$( jf rt curl -XPOST api/search/aql \
160
148
-H ' Content-Type: text/plain' \
161
149
-d " $AQL " )
162
150
163
- # === Extract child names from file names ===
151
+ # Extract child build IDs from JSON file names
164
152
if echo " $RESP " | jq -e ' .results' > /dev/null 2>&1 ; then
165
- echo " Raw AQL results:"
166
- echo " $RESP " | jq ' .results[] | {path: .path, name: .name}'
167
- echo " ---"
168
-
169
- # Extract child build IDs from file names like "132-amzn2023-x86_64-1758073733638.json"
170
- # The pattern is: ${MATRIX_BUILD_ID}-${TIMESTAMP}.json
171
- # We want to extract the matrix build ID (which includes the parent build ID + matrix suffix)
172
- # Filter out the parent build ID itself (e.g., "132" without matrix suffix)
153
+ # Extract matrix build IDs from JSON file names (filter out parent build ID)
173
154
mapfile -t CHILD_BUILD_IDS < <( echo " $RESP " | jq -r ' .results[] | .name' | sed ' s/-[0-9]*\.json$//' | grep -v " ^${PARENT_BUILD_ID} $" | sort -u)
174
155
175
- # All matrix builds have the same build name (the parent build name)
176
- # Create array of build names (all the same) corresponding to each build ID
156
+ # All matrix builds use the same build name
177
157
CHILD_NAMES=()
178
158
for _ in " ${CHILD_BUILD_IDS[@]} " ; do
179
159
CHILD_NAMES+=(" $PARENT_BUILD_NAME " )
180
160
done
181
161
182
- echo " Extracted build IDs:"
183
- for i in " ${! CHILD_BUILD_IDS[@]} " ; do
184
- echo " - ${CHILD_BUILD_IDS[$i]} "
185
- done
186
-
187
- echo " Found ${# CHILD_NAMES[@]} child builds"
188
- echo " Child builds found:"
189
- for i in " ${! CHILD_NAMES[@]} " ; do
190
- echo " - ${CHILD_NAMES[$i]} /${CHILD_BUILD_IDS[$i]} "
191
- done
162
+ echo " Found ${# CHILD_NAMES[@]} child builds to aggregate"
192
163
else
193
- echo " Invalid JSON response or no results field "
164
+ echo " No build-info files found "
194
165
CHILD_NAMES=()
195
166
fi
196
167
@@ -199,33 +170,24 @@ if (( ${#CHILD_NAMES[@]} == 0 )); then
199
170
exit 0
200
171
fi
201
172
202
- # === First, let's see what builds actually exist ===
203
- echo " Listing all builds for build name: ${PARENT_BUILD_NAME} "
204
- LIST_BUILDS=$( run jf rt curl " api/build?buildName=${PARENT_BUILD_NAME} &project=${PROJECT} " 2> /dev/null)
205
- echo " Available builds for ${PARENT_BUILD_NAME} : $LIST_BUILDS "
206
-
207
- # === Append each child build to the parent ===
173
+ # Append each child build to the parent
208
174
for i in " ${! CHILD_NAMES[@]} " ; do
209
175
child_name=" ${CHILD_NAMES[$i]} "
210
176
child_build_id=" ${CHILD_BUILD_IDS[$i]} "
211
177
212
- echo " $child_name is a child build with ID $child_build_id "
213
-
214
- # Check if the child build exists in Artifactory
215
- echo " Checking if build ${child_name} /${child_build_id} exists..."
216
- echo " API URL: api/build/${child_name} /${child_build_id} ?project=${PROJECT} "
178
+ # Check if build exists and append to parent
217
179
BUILD_CHECK=$( run jf rt curl " api/build/${child_name} /${child_build_id} ?project=${PROJECT} " 2> /dev/null)
218
- echo " Build check response: $BUILD_CHECK "
219
180
220
181
if echo " $BUILD_CHECK " | jq -e ' .errors' > /dev/null 2>&1 ; then
221
- echo " Build ${child_name} /${child_build_id} not found in Artifactory, skipping... "
182
+ echo " Skipping ${child_name} /${child_build_id} - not found in Artifactory"
222
183
else
223
- echo " Build ${child_name} /${child_build_id} found! Appending to parent..."
224
- echo " Appending ${child_name} /${child_build_id} -> ${PARENT_BUILD_NAME} /${PARENT_BUILD_ID} "
184
+ echo " Appending ${child_name} /${child_build_id} to parent build"
225
185
run jf rt build-append " $PARENT_BUILD_NAME " " $PARENT_BUILD_ID " \
226
186
" $child_name " " $child_build_id " \
227
187
--project=" $PROJECT "
228
- echo " Append command completed for ${child_name} /${child_build_id} "
229
188
fi
230
189
done
190
+
191
+ # Publish the aggregated parent build
192
+ echo " Publishing aggregated parent build ${PARENT_BUILD_NAME} /${PARENT_BUILD_ID} "
231
193
run jf rt build-publish " $PARENT_BUILD_NAME " " $PARENT_BUILD_ID " --project=" $PROJECT "
0 commit comments