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