limit to 3 builds per job
This commit is contained in:
parent
6bc84f3e06
commit
4914ddc56f
1 changed files with 20 additions and 17 deletions
|
@ -4,7 +4,8 @@
|
||||||
remote_instance=https://builds.robur.coop
|
remote_instance=https://builds.robur.coop
|
||||||
local_user_pass=test:test
|
local_user_pass=test:test
|
||||||
local_instance="http://${local_user_pass}@localhost:3000"
|
local_instance="http://${local_user_pass}@localhost:3000"
|
||||||
limit=100
|
global_limit=100
|
||||||
|
per_job_limit=3 # Limit to 3 builds per job
|
||||||
|
|
||||||
curl_json () {
|
curl_json () {
|
||||||
curl --silent --fail --location --header "Accept: application/json" "$@"
|
curl --silent --fail --location --header "Accept: application/json" "$@"
|
||||||
|
@ -12,10 +13,11 @@ curl_json () {
|
||||||
|
|
||||||
curl_json "${remote_instance}/" | jq -r .jobs[] | {
|
curl_json "${remote_instance}/" | jq -r .jobs[] | {
|
||||||
while read -r job_name; do
|
while read -r job_name; do
|
||||||
|
build_count=0
|
||||||
curl_json "${remote_instance}/job/${job_name}" | jq -r .builds[].uuid | {
|
curl_json "${remote_instance}/job/${job_name}" | jq -r .builds[].uuid | {
|
||||||
while read -r build_uuid; do
|
while read -r build_uuid; do
|
||||||
if [ "$limit" -eq 0 ]; then
|
if [ "$global_limit" -eq 0 ] || [ "$build_count" -ge "$per_job_limit" ]; then
|
||||||
break 2;
|
break 2
|
||||||
fi
|
fi
|
||||||
dest=$(mktemp "builder-${build_uuid}.XXXXXXXXXX")
|
dest=$(mktemp "builder-${build_uuid}.XXXXXXXXXX")
|
||||||
curl --silent --fail "${remote_instance}/job/${job_name}/build/${build_uuid}/exec" > "$dest" && {
|
curl --silent --fail "${remote_instance}/job/${job_name}/build/${build_uuid}/exec" > "$dest" && {
|
||||||
|
@ -23,7 +25,8 @@ curl_json "${remote_instance}/" | jq -r .jobs[] | {
|
||||||
curl --data-binary "@${dest}" "${local_instance}/upload"
|
curl --data-binary "@${dest}" "${local_instance}/upload"
|
||||||
}
|
}
|
||||||
rm -f "$dest"
|
rm -f "$dest"
|
||||||
limit=$((limit - 1))
|
global_limit=$((global_limit - 1))
|
||||||
|
build_count=$((build_count + 1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue