From 9499ba64e7d9ba031c421c7db8d5b59acb6d4f39 Mon Sep 17 00:00:00 2001 From: Varac <varac@varac.net> Date: Wed, 16 Jun 2021 22:47:07 +0200 Subject: [PATCH] Use bash with pipefail to catch errors in scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise such errors like https://open.greenhost.net/openappstack/openappstack/-/jobs/89464 are not catched: $ sh ./install/install-openappstack.sh ✚ generating manifests ✔ manifests build completed ► installing components in flux-system namespace ✗ install failed: exec: "kubectl": executable file not found in $PATH ✚ generating GitRepository source ► applying GitRepository source ✔ GitRepository source created ◎ waiting for GitRepository source reconciliation ✔ GitRepository source reconciliation completed ✔ fetched revision: master/fe6c33028cf097eb96eab1c3f20deef2d1cb1f49 ✚ generating Kustomization ► applying Kustomization ✔ Kustomization created ◎ waiting for Kustomization reconciliation ✔ Kustomization openappstack is ready ✔ applied revision master/fe6c33028cf097eb96eab1c3f20deef2d1cb1f49 --- .gitlab-ci.yml | 6 +++--- install/install-nextcloud.sh | 4 +++- install/install-openappstack.sh | 4 +++- install/install-rocketchat.sh | 4 +++- install/install-velero.sh | 4 +++- install/install-wordpress.sh | 4 +++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56c771dea..4161ed386 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -263,7 +263,7 @@ create-vps: - *debug_information # Creates a VPS based on a custom CI image for which --install-kubernetes # has already run. See CONTRIBUTING.md#ci-pipeline-image for more info - - sh .gitlab/ci_scripts/create_vps.sh + - bash .gitlab/ci_scripts/create_vps.sh # Make sure .ci.env variables are not lost - cat .ci.env >> ${CLUSTER_DIR}/.cluster.env extends: @@ -314,7 +314,7 @@ setup-openappstack: - ls -la . - ls -la ./install - source clusters/${CI_COMMIT_REF_SLUG}/.cluster.env - - sh ./install/install-openappstack.sh + - bash ./install/install-openappstack.sh # TODO: Should also be removed or made up-to-date # Show versions of installed apps/binaries # - cd ansible @@ -432,7 +432,7 @@ single-sign-on-helm-release: stage: install-apps script: - *debug_information - - sh ./install/install-${APP}.sh + - bash ./install/install-${APP}.sh extends: - .ssh_setup interruptible: true diff --git a/install/install-nextcloud.sh b/install/install-nextcloud.sh index c515e9839..e6aea0346 100755 --- a/install/install-nextcloud.sh +++ b/install/install-nextcloud.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -euo pipefail # First, add some overrides for values that are only useful in CI kubectl apply -n oas-apps -f $( dirname "${BASH_SOURCE[0]}" )/nextcloud-values-override.yaml diff --git a/install/install-openappstack.sh b/install/install-openappstack.sh index 84000f331..0b0efe56a 100755 --- a/install/install-openappstack.sh +++ b/install/install-openappstack.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -euo pipefail flux install \ --network-policy=false \ diff --git a/install/install-rocketchat.sh b/install/install-rocketchat.sh index 576e21582..a0364c459 100755 --- a/install/install-rocketchat.sh +++ b/install/install-rocketchat.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -euo pipefail # This kustomization's only purpose is to add the kustomization that is in the # flxu2/cluster/optional/rocketchat folder. After this kustomization is applied diff --git a/install/install-velero.sh b/install/install-velero.sh index 7b849b978..3b85c1f77 100755 --- a/install/install-velero.sh +++ b/install/install-velero.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -euo pipefail # This kustomization's only purpose is to add the kustomization that is in the # flxu2/cluster/optional/velero folder. After this kustomization is applied diff --git a/install/install-wordpress.sh b/install/install-wordpress.sh index 40d93607b..2db41fdd6 100755 --- a/install/install-wordpress.sh +++ b/install/install-wordpress.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -euo pipefail # This kustomization's only purpose is to add the kustomization that is in the # flxu2/cluster/optional/wordpress folder. After this kustomization is applied -- GitLab