blob: 2a7fbc25e2cb2ea54b153360e123b22f8cc8d103 [file] [log] [blame]
Arthur She0cfe3642025-01-10 21:49:38 -08001#!/bin/bash
2#
3set -ex
4
Arthur She705e61e2025-02-13 21:39:48 -08005TO_BUILD_FILE="${WORKSPACE}/TO_BUILD"
Arthur Sheb94eb852025-01-17 16:22:47 -08006JOB_URL=${JOB_URL//http:/https:}
Arthur She705e61e2025-02-13 21:39:48 -08007last_build=$((${BUILD_NUMBER}-1))
Arthur Sheae47e4a2025-02-13 22:09:54 -08008API_URL="${JOB_URL}/${last_build}/api/json"
Arthur She705e61e2025-02-13 21:39:48 -08009if [ ${last_build} -eq 0 ]; then
10 echo "This is the first build"
Arthur She0cfe3642025-01-10 21:49:38 -080011 touch ${TO_BUILD_FILE}
12else
Arthur She705e61e2025-02-13 21:39:48 -080013 repos_to_check="trusted-firmware-a tf-a-tests tf-a-ci-scripts"
14 last_build=$(curl -s ${API_URL})
15 last_build_ts=$(echo ${last_build} | jq '.timestamp')
16 last_build_ts=$((${last_build_ts}/1000))
17 last_build_result=$(echo ${last_build} | jq -r '.result')
Arthur She0cfe3642025-01-10 21:49:38 -080018
Arthur She263a21d2025-02-13 21:51:57 -080019 if [ "${FORCE_TO_BUILD}" = "true" -o "${last_build_result}" != "SUCCESS" ]; then
Arthur She705e61e2025-02-13 21:39:48 -080020 touch ${TO_BUILD_FILE}
21 else
22 for r in ${repos_to_check}
23 do
24 pushd ${SHARE_FOLDER}/${r}
25 last_commit_ts=$(git show --no-patch --format=%ct)
26 # if the last commit was not covered by the last build
27 # the new build will be proceeded
28 if [ ${last_commit_ts} -ge ${last_build_ts} ]; then
29 touch ${TO_BUILD_FILE}
30 break
31 fi
32 popd
33 done
34 fi
35fi