add custom delay to external triggers

add `external_trigger_delay_hours` var to jenkins-vars.yml that allows external triggers
 to check the time of last build and skip trigger based on custom delay
This commit is contained in:
aptalca 2020-11-24 17:09:05 -05:00
parent 6f6d917d65
commit fa8da80789
2 changed files with 6 additions and 0 deletions

View File

@ -45,3 +45,4 @@ optional_block_1: false
changelogs: []
custom_external_trigger: ""
custom_package_trigger: ""
external_trigger_delay_hours: 0

View File

@ -120,6 +120,11 @@ jobs:
elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-{{ project_name }}/job/{{ ls_branch }}/lastBuild/api/json | jq -r '.building') == "true" ]; then
echo "**** New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting ****"
exit 0
{% if external_trigger_delay_hours > 0 %}
elif [[ $(( $(date +%s%3N) - $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-{{ project_name }}/job/{{ ls_branch }}/lastBuild/api/json | jq -r '.timestamp') )) -lt $(( {{ external_trigger_delay_hours }} * 3600000 )) ]]; then
echo "**** New version ${EXT_RELEASE} found; but the last build was less than {{ external_trigger_delay_hours }} hours ago; skipping trigger ****"
exit 0
{% endif %}
else
echo "**** New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build ****"
response=$(curl -iX POST \