From d78dad7ffa60903c88a807f9a0abcc95ed0252ce Mon Sep 17 00:00:00 2001 From: Wulf Thimm Date: Fri, 18 Feb 2022 14:29:58 +0000 Subject: [PATCH] forcing the werft job to fail if the branch name is too long to support preview-environments --- .werft/build.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.werft/build.ts b/.werft/build.ts index ff2877a071895a..36b527ea89af69 100644 --- a/.werft/build.ts +++ b/.werft/build.ts @@ -44,6 +44,19 @@ Tracing.initialize() async function run(context: any) { const config = jobConfig(werft, context) + //TODO: This is only a temporary solution and needs to be removed when we migrate to one prev-environment per cluster + // Because of a workspace label the branch name that can be used to create a preview environment is limited to 20 chars + // echo -n "gitpod.io/registry-facade_ready_ns_staging-" | wc -c + if (!config.noPreview) { + werft.phase("check-branchname","This checks if the branchname is to long to create a preview-environment successfully.") + const maxBranchNameLength = 20; + if (config.previewEnvironment.destname.length > maxBranchNameLength) { + werft.fail("check-branchname", `The branch name ${config.previewEnvironment.destname} is more than ${maxBranchNameLength} character. Please choose a shorter name!`) + } + werft.done("check-branchname") + } + + await validateChanges(werft) await prepare(werft) await buildAndPublish(werft, config)