Arthur She | 0cfe364 | 2025-01-10 21:49:38 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | set -ex |
| 4 | |
Arthur She | 705e61e | 2025-02-13 21:39:48 -0800 | [diff] [blame] | 5 | TO_BUILD_FILE="${WORKSPACE}/TO_BUILD" |
Arthur She | b94eb85 | 2025-01-17 16:22:47 -0800 | [diff] [blame] | 6 | JOB_URL=${JOB_URL//http:/https:} |
Arthur She | 705e61e | 2025-02-13 21:39:48 -0800 | [diff] [blame] | 7 | last_build=$((${BUILD_NUMBER}-1)) |
Arthur She | ae47e4a | 2025-02-13 22:09:54 -0800 | [diff] [blame] | 8 | API_URL="${JOB_URL}/${last_build}/api/json" |
Arthur She | 705e61e | 2025-02-13 21:39:48 -0800 | [diff] [blame] | 9 | if [ ${last_build} -eq 0 ]; then |
| 10 | echo "This is the first build" |
Arthur She | 0cfe364 | 2025-01-10 21:49:38 -0800 | [diff] [blame] | 11 | touch ${TO_BUILD_FILE} |
| 12 | else |
Arthur She | 705e61e | 2025-02-13 21:39:48 -0800 | [diff] [blame] | 13 | 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 She | 0cfe364 | 2025-01-10 21:49:38 -0800 | [diff] [blame] | 18 | |
Arthur She | 263a21d | 2025-02-13 21:51:57 -0800 | [diff] [blame] | 19 | if [ "${FORCE_TO_BUILD}" = "true" -o "${last_build_result}" != "SUCCESS" ]; then |
Arthur She | 705e61e | 2025-02-13 21:39:48 -0800 | [diff] [blame] | 20 | 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 |
| 35 | fi |