jenkins loop: update branch on start (#34649)

refresh
pull/34652/head
Maxime Desroches 2 months ago committed by GitHub
parent 9167e3dcf6
commit 00acf26908
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 26
      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,21 +37,9 @@ 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) )
@ -69,7 +52,6 @@ function loop() {
sleep 5
done
echo ""
fi
# Wait for all builds to end
while true; do

Loading…
Cancel
Save