From 2c411f0a316a63c0e716414b0d775639267dbbe3 Mon Sep 17 00:00:00 2001 From: Bjarke Istrup Pedersen Date: Wed, 3 Jul 2024 09:40:04 +0200 Subject: Move branch filter logic By moving it up here, we make sure only jobs that should be built is added to the JOBS array in the first place. This is a better way, since the skipped jobs won't occupy the build slots (since we take X number of jobs from the JOBS array for each batch, for a CONCURRENT_JOBS_COUNT of 10 - if 6 is skipped, only 4 jobs will be started). Now, they are not added to the JOBS array, so the rest works as intended. --- auto/helper-logic | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/auto/helper-logic b/auto/helper-logic index 7642c9a..7c1360c 100644 --- a/auto/helper-logic +++ b/auto/helper-logic @@ -423,6 +423,11 @@ function BuildJobs { for BRANCH in $BRANCHES do + # Branch filter + if ! echo $BRANCH | grep -E "$SELECTED_BRANCH_REGEX" > /dev/null; then + continue + fi + JOBS+=( "$JOB_NAME|$BRANCH" ) done done < <(cat $1 | jq -c '.[]') @@ -484,12 +489,6 @@ function BuildJobs { JOB_NAME="${jobSplit[0]}" JOB_BRANCH="${jobSplit[1]}" - # Branch filter - if ! echo $JOB_BRANCH | grep -E "$SELECTED_BRANCH_REGEX" > /dev/null; then - PrintJobExcluded $JOB_NAME $JOB_BRANCH - continue - fi - # Download job data and parse it. URL="${JENKINS_URL}/job/${JOB_NAME}/job/${JOB_BRANCH}/lastBuild/api/json" DATA=$(curl -Ss -g --fail-with-body "$URL") @@ -565,12 +564,6 @@ function BuildJobs { JOB_NAME="${jobSplit[0]}" JOB_BRANCH="${jobSplit[1]}" - # Branch filter - if ! echo $JOB_BRANCH | grep -E "$SELECTED_BRANCH_REGEX" > /dev/null; then - PrintJobExcluded $JOB_NAME $JOB_BRANCH - continue - fi - # Download job data and parse it. URL="${JENKINS_URL}/job/${JOB_NAME}/job/${JOB_BRANCH}/lastBuild/api/json" DATA=$(curl -Ss -g --fail-with-body "$URL") -- cgit v1.2.3