From 00acf26908c73c2942df65b1c77d67cd7c269e06 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Thu, 20 Feb 2025 21:35:09 -0800 Subject: [PATCH] jenkins loop: update branch on start (#34649) refresh --- scripts/jenkins_loop_test.sh | 48 +++++++++++------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/scripts/jenkins_loop_test.sh b/scripts/jenkins_loop_test.sh index a21ecb1bd4..0b242e98dc 100755 --- a/scripts/jenkins_loop_test.sh +++ b/scripts/jenkins_loop_test.sh @@ -13,6 +13,8 @@ RUNS="20" COOKIE_JAR=/tmp/cookies CRUMB=$(curl -s --cookie-jar $COOKIE_JAR 'https://jenkins.comma.life/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)') +FIRST_LOOP=1 + function loop() { JENKINS_BRANCH="__jenkins_loop_${BRANCH}" API_ROUTE="https://jenkins.comma.life/job/openpilot/job/$JENKINS_BRANCH" @@ -20,15 +22,8 @@ function loop() { for run in $(seq 1 $((RUNS / 2))); do N=2 - TEST_BUILDS=() - - # Try to find previous builds - ALL_BUILDS=( $(curl -s $API_ROUTE/api/json | jq .builds.[].number 2> /dev/null || :) ) - - # Jenkins branches get deactivated after some time - BUILDABLE=$(curl -s $API_ROUTE/api/json | jq -e '.buildable' 2> /dev/null || echo "false") - if [[ ${#ALL_BUILDS[@]} -eq 0 || $BUILDABLE != "true" ]]; then + if [[ $FIRST_LOOP ]]; then TEMP_DIR=$(mktemp -d) GIT_LFS_SKIP_SMUDGE=1 git clone --quiet -b $BRANCH --depth=1 --no-tags git@github.com:commaai/openpilot $TEMP_DIR git -C $TEMP_DIR checkout --quiet -b $JENKINS_BRANCH @@ -42,34 +37,21 @@ function loop() { echo 'waiting on Jenkins...' echo '' sleep 90 - else - # Found some builds. Wait for them to end if they are still running - for i in ${ALL_BUILDS[@]}; do - running=$(curl -s $API_ROUTE/$i/api/json/ | jq .inProgress) - if [[ $running == "false" ]]; then - continue - fi - TEST_BUILDS=( ${ALL_BUILDS[@]} ) - N=${#TEST_BUILDS[@]} - break - done + FIRST_LOOP="" fi - # No running builds found - if [[ ${#TEST_BUILDS[@]} -eq 0 ]]; then - FIRST_BUILD=$(curl -s $API_ROUTE/api/json | jq .nextBuildNumber) - LAST_BUILD=$((FIRST_BUILD+N-1)) - TEST_BUILDS=( $(seq $FIRST_BUILD $LAST_BUILD) ) + FIRST_BUILD=$(curl -s $API_ROUTE/api/json | jq .nextBuildNumber) + LAST_BUILD=$((FIRST_BUILD+N-1)) + TEST_BUILDS=( $(seq $FIRST_BUILD $LAST_BUILD) ) - # Start N new builds - for i in ${TEST_BUILDS[@]}; - do - echo "Starting build $i" - curl -s --output /dev/null --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/build?delay=0sec - sleep 5 - done - echo "" - fi + # Start N new builds + for i in ${TEST_BUILDS[@]}; + do + echo "Starting build $i" + curl -s --output /dev/null --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/build?delay=0sec + sleep 5 + done + echo "" # Wait for all builds to end while true; do