From e3bb4595a6a0c06a515815069a76b954e92215bc Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Fri, 10 Jun 2022 21:45:34 +0200 Subject: [PATCH 1/2] jenkins_build_blocks --- automation/jenkins_build-blocks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/jenkins_build-blocks.sh b/automation/jenkins_build-blocks.sh index b3a66bc05..963a0487f 100755 --- a/automation/jenkins_build-blocks.sh +++ b/automation/jenkins_build-blocks.sh @@ -83,7 +83,7 @@ __build_hostos_blocks() { _appname="${_device_type}-${_block}" balena_build_block "${_appname}" "${_device_type}" "${_packages}" "${_balenaos_account}" "${_api_env}" _release_version=$(balena_lib_get_os_version) - balena_deploy_block "${_appname}" "${_device_type}" "${_bootable:-0}" "${_image_path:-"${WORKSPACE}/deploy-jenkins/${_appName}-${_release_version}.docker"}" + balena_deploy_block "${_appname}" "${_device_type}" "${_bootable:-0}" "${_final}" "${_image_path:-"${WORKSPACE}/deploy-jenkins/${_appName}-${_release_version}.docker"}" done # Remove packages folder from deploy directory From 7a2f8260eb18f066f55ea296b85c8cf730532660 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Tue, 8 Jun 2021 11:29:38 +0200 Subject: [PATCH 2/2] jenkins_build.sh: Add building and deployment of blocks If blocks are defined in the job, build and deploy them. Change-type: patch Signed-off-by: Alex Gonzalez --- automation/jenkins_build.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 0b4800035..a4256ac73 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -143,9 +143,34 @@ else popd > /dev/null 2>&1 fi -"${automation_dir}"/../build/balena-build.sh -d "${MACHINE}" -s "${JENKINS_PERSISTENT_WORKDIR}" -a "$(balena_lib_environment)" -g "${BARYS_ARGUMENTS_VAR}" +"${automation_dir}"/../build/balena-build.sh -d "${MACHINE}" -s "${JENKINS_PERSISTENT_WORKDIR}" -a "$(balena_lib_environment)" -g "${BARYS_ARGUMENTS_VAR}" -b "-c image_docker" -i "balena-image" # Do not check for artifacts as when discontinuing device types build artifacts are not created, but device-type.json needs to be deployed to mark the device as discontinued +image_path=$(find "${WORKSPACE}/build/tmp/work/" -name "balena-image-${MACHINE}*.docker" -type l) +if [ -L "${_image_path}" ]; then + echo "[ERROR]:balena_deploy_hostapp: No hostapp to release" + exit 1 +fi +balena_deploy_block "$(balena_lib_get_slug "${MACHINE}")" "${MACHINE}" "${_bootable:-1}" "${deploy}" "${image_path}" + +# Build and release blocks +if [ -n "${blocks}" ]; then + [ "${deploy}" = "no" ] && _final="" + "${automation_dir}/jenkins_build-blocks.sh" -d "${MACHINE}" -a "$(balena_lib_environment)" -b "${blocks}" -t "$(balena_lib_token)" -s "${JENKINS_PERSISTENT_WORKDIR}" "${_final:+"-p"}" +fi + +# Release hostos +osapp="${MACHINE}-hostos" +blocks_apps="${MACHINE}" +for block in ${blocks}; do + blocks_apps="${blocks_apps} ${MACHINE}-${block}" +done +balena_deploy_hostos "${osapp}" "${blocks_apps}" "${MACHINE}" "${deploy}" +BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a HOSTOS_APPS=${osapp}" + +# Build image +"${automation_dir}"/../build/balena-build.sh -d "${MACHINE}" -s "${JENKINS_PERSISTENT_WORKDIR}" -a "$(balena_lib_environment)" -g "${BARYS_ARGUMENTS_VAR}" + if [ "$ENABLE_TESTS" = true ]; then # Run the test script in the device specific repository if [ -f "$WORKSPACE/tests/start.sh" ]; then