Skip to content

Commit

Permalink
build: fix builds using grep to match a string.
Browse files Browse the repository at this point in the history
Before: `grep -Eo` was used in a couple places in release scripts
where it might not find the string being searched for, the non-zero
return code wasn't handled and the script should have continued
executing.

Why: The release scripts were erroring out when they should have
continued executing.

Now: The non-zero return code is handled by adding a `|| echo""` to the
commands.

This was discovered by PR cockroachdb#54661 causing master to fail builds in Make
and Publish Build.

Release note: None
  • Loading branch information
jlinder committed Oct 13, 2020
1 parent 03e8d32 commit 5082492
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions build/release/teamcity-make-and-publish-build.sh
Expand Up @@ -9,8 +9,10 @@ export BUILDER_HIDE_GOPATH_SRC=1

build/builder.sh make .buildinfo/tag
build_name="${TAG_NAME:-$(cat .buildinfo/tag)}"
release_branch="$(echo "$build_name" | grep -Eo "^v[0-9]+\.[0-9]+")"
is_custom_build="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^custombuild-")"

# On no match, `grep -Eo` returns 1. `|| echo""` makes the script not error.
release_branch="$(echo "$build_name" | grep -Eo "^v[0-9]+\.[0-9]+" || echo"")"
is_custom_build="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^custombuild-" || echo "")"

if [[ -z "${DRY_RUN}" ]] ; then
bucket="${BUCKET-cockroach-builds}"
Expand Down
4 changes: 3 additions & 1 deletion build/release/teamcity-mark-build.sh
Expand Up @@ -8,7 +8,9 @@ source "$(dirname "${0}")/teamcity-support.sh"
mark_build() {
tc_start_block "Variable Setup"
build_label=$1
release_branch="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^v[0-9]+\.[0-9]+")"

# On no match, `grep -Eo` returns 1. `|| echo""` makes the script not error.
release_branch="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^v[0-9]+\.[0-9]+" || echo"")"

if [[ -z "${DRY_RUN}" ]] ; then
google_credentials=$GOOGLE_COCKROACH_CLOUD_IMAGES_CREDENTIALS
Expand Down

0 comments on commit 5082492

Please sign in to comment.