We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd36566 commit c4a2495Copy full SHA for c4a2495
hooks/command
@@ -4,7 +4,12 @@ set -euo pipefail
4
5
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
6
7
-job_name="${BUILDKITE_PIPELINE_SLUG}-${BUILDKITE_BUILD_NUMBER}-$(head -c 5 /dev/urandom | base32 | tr '[:upper:]' '[:lower:]')"
+# Ensure a name is a valid k8s resource name.
8
+function sanitize() {
9
+ echo "$@" | sed -E 's/[^A-Za-z0-9]/-/g' | sed -E 's/^[^a-zA-Z0-9]|[^a-zA-Z0-9]$//' | cut -c 1-63
10
+}
11
+
12
+job_name=$(sanitize "${BUILDKITE_PIPELINE_SLUG}-${BUILDKITE_BUILD_NUMBER}-$(head -c 5 /dev/urandom | base32 | tr '[:upper:]' '[:lower:]')")
13
echo "${job_name}" > /tmp/job_name
14
15
if [[ ${BUILDKITE_TIMEOUT:-"false"} == "false" ]]; then
0 commit comments