summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordd <dd@wx.tnyzeq.icu>2024-07-12 18:35:27 +0200
committerdd <dd@wx.tnyzeq.icu>2024-07-12 18:35:27 +0200
commit06764ffd8e316378d95f7feb37ba1aa4fc3acdce (patch)
tree3c309219e1ec0937e5bdd5779fc11a3e522bdaad
parent6c7ddb626bab489dbc684d5416b185fdad493d4e (diff)
downloadvyos-jenkins-06764ffd8e316378d95f7feb37ba1aa4fc3acdce.tar.gz
vyos-jenkins-06764ffd8e316378d95f7feb37ba1aa4fc3acdce.zip
improved automated job provisioning to account for already expired runs
-rw-r--r--auto/helper-logic32
1 files changed, 24 insertions, 8 deletions
diff --git a/auto/helper-logic b/auto/helper-logic
index 083f086..3c655b9 100644
--- a/auto/helper-logic
+++ b/auto/helper-logic
@@ -461,20 +461,36 @@ function ProvisionJobs {
continue
fi
- URL="${JENKINS_URL}/job/${JOB_NAME}/job/${JOB_BRANCH}/1/api/json"
+ completed=false
+ started=true
+ url="${JENKINS_URL}/job/${JOB_NAME}/job/${JOB_BRANCH}/api/json"
+ nextBuildNumber=$(curl -Ss -g --fail-with-body "$url" | jq -r .nextBuildNumber)
+ if [ $nextBuildNumber -gt 2 ]; then
+ completed=true
+ else
+ url="${JENKINS_URL}/job/${JOB_NAME}/job/${JOB_BRANCH}/1/api/json"
+ if [ "$(curl -o /dev/null -s -w "%{http_code}\n" "${url}")" -eq 404 ]; then
+ started=false
+ fi
+ fi
- if [ "$(curl -o /dev/null -s -w "%{http_code}\n" "${URL}")" -eq 404 ]; then
+ if ! $started; then
# The indexing hasn't started for this branch yet.
PrintJobNotStarted $JOB_NAME $JOB_BRANCH
FINISHED_THIS_RUN="false"
else
# Indexing has started.
- RESULT=$(curl -Ss -g --fail-with-body "$URL" | jq -r .result)
- if [[ "${RESULT}" != "SUCCESS" ]]; then
- # But it hasn't finished yet.
- PrintJobRunning $JOB_NAME $JOB_BRANCH
- FINISHED_THIS_RUN="false"
- else
+ if ! $completed; then
+ RESULT=$(curl -Ss -g --fail-with-body "$url" | jq -r .result)
+ if [[ "${RESULT}" != "SUCCESS" ]]; then
+ # But it hasn't finished yet.
+ PrintJobRunning $JOB_NAME $JOB_BRANCH
+ FINISHED_THIS_RUN="false"
+ else
+ completed=true
+ fi
+ fi
+ if $completed; then
PrintJobCompleted $JOB_NAME $JOB_BRANCH
fi
fi