builder-web/populate-local.sh
Reynir Björnsson 125b163b31 Add more json to endpoints, populate-local.sh
Some basic json is added to the endpoints that list jobs and builds.

With this a script populate-local.sh can be used to fetch a number of
builds from a remote instance and upload them to a local instance. This
is useful for populating an instance with real builds for testing
purposes.

Closes #11.
2025-01-16 12:04:55 +01:00

30 lines
888 B
Bash
Executable file

#!/bin/sh
# Edit these values to your needs:
remote_instance=https://builds.robur.coop
local_user_pass=test:test
local_instance="http://${local_user_pass}@localhost:3000"
limit=100
curl_json () {
curl --silent --fail --location --header "Accept: application/json" "$@"
}
curl_json "${remote_instance}/" | jq -r .jobs[] | {
while read -r job_name; do
curl_json "${remote_instance}/job/${job_name}" | jq -r .builds[].uuid | {
while read -r build_uuid; do
if [ "$limit" -eq 0 ]; then
break 2;
fi
dest=$(mktemp "builder-${build_uuid}.XXXXXXXXXX")
curl --silent --fail "${remote_instance}/job/${job_name}/build/${build_uuid}/exec" > "$dest" && {
echo "Uploading $job_name build $build_uuid"
curl --data-binary "@${dest}" "${local_instance}/upload"
}
rm -f "$dest"
limit=$((limit - 1))
done
}
done
}