ci: keep buildx logs alive for jenkins
This commit is contained in:
Vendored
+64
@@ -77,6 +77,36 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh """
|
sh """
|
||||||
set -e
|
set -e
|
||||||
|
run_with_heartbeat() {
|
||||||
|
log_file="\$1"
|
||||||
|
shift
|
||||||
|
rm -f "\$log_file"
|
||||||
|
: > "\$log_file"
|
||||||
|
"\$@" >"\$log_file" 2>&1 &
|
||||||
|
cmd_pid=\$!
|
||||||
|
last_line=0
|
||||||
|
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
|
||||||
|
if [ -f "\$log_file" ]; then
|
||||||
|
total_lines=\$(wc -l < "\$log_file" || echo 0)
|
||||||
|
else
|
||||||
|
total_lines=0
|
||||||
|
fi
|
||||||
|
if [ "\$total_lines" -gt "\$last_line" ]; then
|
||||||
|
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
|
||||||
|
last_line=\$total_lines
|
||||||
|
else
|
||||||
|
echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
done
|
||||||
|
wait "\$cmd_pid"
|
||||||
|
if [ -f "\$log_file" ]; then
|
||||||
|
total_lines=\$(wc -l < "\$log_file" || echo 0)
|
||||||
|
if [ "\$total_lines" -gt "\$last_line" ]; then
|
||||||
|
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
||||||
sudo docker buildx create \
|
sudo docker buildx create \
|
||||||
--name ${BUILDER_NAME} \
|
--name ${BUILDER_NAME} \
|
||||||
@@ -92,10 +122,12 @@ pipeline {
|
|||||||
fi
|
fi
|
||||||
sudo docker buildx inspect --builder ${BUILDER_NAME} --bootstrap >/dev/null
|
sudo docker buildx inspect --builder ${BUILDER_NAME} --bootstrap >/dev/null
|
||||||
echo 'Building and pushing multi-arch API image: ${API_IMAGE_TAGGED}'
|
echo 'Building and pushing multi-arch API image: ${API_IMAGE_TAGGED}'
|
||||||
|
run_with_heartbeat .jenkins-api-buildx.log \
|
||||||
sudo docker buildx build \
|
sudo docker buildx build \
|
||||||
--builder ${BUILDER_NAME} \
|
--builder ${BUILDER_NAME} \
|
||||||
--platform ${TARGET_PLATFORMS} \
|
--platform ${TARGET_PLATFORMS} \
|
||||||
--network host \
|
--network host \
|
||||||
|
--progress=plain \
|
||||||
--provenance=false \
|
--provenance=false \
|
||||||
--build-arg HTTP_PROXY=http://192.168.5.200:7890 \
|
--build-arg HTTP_PROXY=http://192.168.5.200:7890 \
|
||||||
--build-arg HTTPS_PROXY=http://192.168.5.200:7890 \
|
--build-arg HTTPS_PROXY=http://192.168.5.200:7890 \
|
||||||
@@ -116,6 +148,36 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh """
|
sh """
|
||||||
set -e
|
set -e
|
||||||
|
run_with_heartbeat() {
|
||||||
|
log_file="\$1"
|
||||||
|
shift
|
||||||
|
rm -f "\$log_file"
|
||||||
|
: > "\$log_file"
|
||||||
|
"\$@" >"\$log_file" 2>&1 &
|
||||||
|
cmd_pid=\$!
|
||||||
|
last_line=0
|
||||||
|
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
|
||||||
|
if [ -f "\$log_file" ]; then
|
||||||
|
total_lines=\$(wc -l < "\$log_file" || echo 0)
|
||||||
|
else
|
||||||
|
total_lines=0
|
||||||
|
fi
|
||||||
|
if [ "\$total_lines" -gt "\$last_line" ]; then
|
||||||
|
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
|
||||||
|
last_line=\$total_lines
|
||||||
|
else
|
||||||
|
echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
done
|
||||||
|
wait "\$cmd_pid"
|
||||||
|
if [ -f "\$log_file" ]; then
|
||||||
|
total_lines=\$(wc -l < "\$log_file" || echo 0)
|
||||||
|
if [ "\$total_lines" -gt "\$last_line" ]; then
|
||||||
|
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
||||||
sudo docker buildx create \
|
sudo docker buildx create \
|
||||||
--name ${BUILDER_NAME} \
|
--name ${BUILDER_NAME} \
|
||||||
@@ -131,10 +193,12 @@ pipeline {
|
|||||||
fi
|
fi
|
||||||
sudo docker buildx inspect --builder ${BUILDER_NAME} --bootstrap >/dev/null
|
sudo docker buildx inspect --builder ${BUILDER_NAME} --bootstrap >/dev/null
|
||||||
echo 'Building and pushing multi-arch Web image: ${WEB_IMAGE_TAGGED}'
|
echo 'Building and pushing multi-arch Web image: ${WEB_IMAGE_TAGGED}'
|
||||||
|
run_with_heartbeat .jenkins-web-buildx.log \
|
||||||
sudo docker buildx build \
|
sudo docker buildx build \
|
||||||
--builder ${BUILDER_NAME} \
|
--builder ${BUILDER_NAME} \
|
||||||
--platform ${TARGET_PLATFORMS} \
|
--platform ${TARGET_PLATFORMS} \
|
||||||
--network host \
|
--network host \
|
||||||
|
--progress=plain \
|
||||||
--provenance=false \
|
--provenance=false \
|
||||||
--build-arg NODE_IMAGE=${WEB_NODE_IMAGE} \
|
--build-arg NODE_IMAGE=${WEB_NODE_IMAGE} \
|
||||||
--build-arg NGINX_IMAGE=${WEB_NGINX_IMAGE} \
|
--build-arg NGINX_IMAGE=${WEB_NGINX_IMAGE} \
|
||||||
|
|||||||
Reference in New Issue
Block a user