blob: 574c306ade957c3f1eb7856bc9eed95209365714 [file] [log] [blame]
Arthur She0cfe3642025-01-10 21:49:38 -08001#!/bin/bash
2#
3set -ex
4
5last_build=$((${BUILD_NUMBER}-1))
Arthur Sheb94eb852025-01-17 16:22:47 -08006JOB_URL=${JOB_URL//http:/https:}
Arthur She0cfe3642025-01-10 21:49:38 -08007API_URL="${JOB_URL}/${last_build}/api/json"
8
9TO_BUILD_FILE="${WORKSPACE}/TO_BUILD"
10repos_to_check="trusted-firmware-a tf-a-tests tf-a-ci-scripts"
11last_build=$(curl -s ${API_URL})
12last_build_ts=$(echo ${last_build} | jq '.timestamp')
13last_build_ts=$((${last_build_ts}/1000))
14last_build_result=$(echo ${last_build} | jq -r '.result')
15
16if [ "${FORCE_TO_BUILD}" = "true" -o "${last_build_result}" = "FAILURE" ]; then
17 touch ${TO_BUILD_FILE}
18else
19 for r in ${repos_to_check}
20 do
21 pushd ${SHARE_FOLDER}/${r}
22 last_commit_ts=$(git show --no-patch --format=%ct)
23 # if the last commit was not covered by the last build
24 # the new build will be proceeded
25 if [ ${last_commit_ts} -ge ${last_build_ts} ]; then
26 touch ${TO_BUILD_FILE}
27 break
28 fi
29 popd
30 done
31fi
32