Skip to content

Commit 4094af3

Browse files
committed
balena-build-block: Allow to specify the deploy dir
This allows to use the script outside of the Jenkins context. Change-type: patch Signed-off-by: Alex Gonzalez <alexg@balena.io>
1 parent 45d04e8 commit 4094af3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

automation/entry_scripts/balena-build-block.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ source "${script_dir}/balena-lib.inc"
1212
[ -z "${PACKAGES}" ] && echo "list of packages to install without dependencies" && exit 1
1313
[ -z "${RELEASE_VERSION}" ] && echo "A release version needs to be defined" && exit 1
1414
[ -z "${WORKSPACE}" ] && echo "Workspace needs to be defined" && exit 1
15+
DEPLOY_DIR="${DEPLOY_DIR:-"${WORKSPACE}/deploy-jenkins"}"
1516

1617
[ -z "${PACKAGE_TYPE}" ] && PACKAGE_TYPE="ipk"
1718

@@ -63,10 +64,10 @@ echo "LABEL ${BALENA_HOSTOS_BLOCK_REQUIRES_REBOOT}=1" >> "${TMPDIR}/Dockerfile"
6364
echo "LABEL ${BALENA_HOSTOS_BLOCK_STORE}=data" >> "${TMPDIR}/Dockerfile"
6465

6566
# Copy local package feed to context if available from previous build step
66-
if [ -d "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" ]; then
67+
if [ -d "${DEPLOY_DIR}/${PACKAGE_TYPE}" ]; then
6768
ARCH_LIST=""
6869
mkdir -p "${TMPDIR}/feed"
69-
cp -r "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" "${TMPDIR}/feed/"
70+
cp -r "${DEPLOY_DIR}/${PACKAGE_TYPE}" "${TMPDIR}/feed/"
7071
# Extract package architecture list from feed
7172
# Each architecture is one directory
7273
while IFS=$'\n' read -r dir; do
@@ -75,7 +76,7 @@ if [ -d "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" ]; then
7576
else
7677
ARCH_LIST="${ARCH_LIST} ${dir}"
7778
fi
78-
done< <(find "${WORKSPACE}/deploy-jenkins/${PACKAGE_TYPE}" -mindepth 1 -maxdepth 1 -type d | xargs -I{} basename {})
79+
done< <(find "${DEPLOY_DIR}/${PACKAGE_TYPE}" -mindepth 1 -maxdepth 1 -type d | xargs -I{} basename {})
7980
else
8081
proto=${FEED_URL%:*}
8182
if [ -z "${FEED_URL}" ] || [ "${proto}" = "file" ]; then
@@ -91,8 +92,8 @@ docker rmi -f $(docker images --filter "label=${BALENA_HOSTOS_BLOCK_CLASS}" --fo
9192

9293
if balena build --logs --nocache --deviceType "${MACHINE}" --arch "${ARCH}" --buildArg PACKAGES="${PACKAGES}" --buildArg ARCH_LIST="${ARCH_LIST}" --buildArg NAMESPACE="${NAMESPACE:-resin}"; then
9394
image_id=$(docker images --filter "label=${BALENA_HOSTOS_BLOCK_CLASS}" --format "{{.ID}}")
94-
mkdir -p "${WORKSPACE}/deploy-jenkins"
95-
docker save "${image_id}" > "${WORKSPACE}/deploy-jenkins/${APPNAME}-${RELEASE_VERSION}.docker"
95+
mkdir -p "${DEPLOY_DIR}"
96+
docker save "${image_id}" > "${DEPLOY_DIR}/${APPNAME}-${RELEASE_VERSION}.docker"
9697
else
9798
echo "[ERROR] Fail to build"
9899
exit 1

0 commit comments

Comments
 (0)