lts-check-last-commit.sh: fix bug

Change-Id: I44ef966e4b71049392cc385d98e3671399c593f2
Signed-off-by: Arthur She <arthur.she@linaro.org>
diff --git a/scripts/lts-check-last-commit.sh b/scripts/lts-check-last-commit.sh
index 02a8739..2a7fbc2 100755
--- a/scripts/lts-check-last-commit.sh
+++ b/scripts/lts-check-last-commit.sh
@@ -4,8 +4,8 @@
 
 TO_BUILD_FILE="${WORKSPACE}/TO_BUILD"
 JOB_URL=${JOB_URL//http:/https:}
-API_URL="${JOB_URL}/${last_build}/api/json"
 last_build=$((${BUILD_NUMBER}-1))
+API_URL="${JOB_URL}/${last_build}/api/json"
 if [ ${last_build} -eq 0 ]; then
     echo "This is the first build"
     touch ${TO_BUILD_FILE}