Skip to content

Commit

Permalink
Get build number from BUILD_NUMBER file if not in a repo (#7922)
Browse files Browse the repository at this point in the history
* Break $(shell) function into multiple lines for readability

* Get build number from BUILD_NUMBER file if not in a git repo
  • Loading branch information
zrhoffman authored Jan 24, 2024
1 parent 96d300e commit 13488f8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion infrastructure/cdn-in-a-box/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ TC_DIR := $(CIAB_DIR_RELATIVE)../..
PKG_COMMAND := $(TC_DIR)/pkg
PKG_FLAGS := -v -$(RHEL_VERSION)
BUILD_SUFFIX := _build
BUILD_NUMBER := $(shell bash -c 'set -o pipefail -o xtrace; git describe --long --tags --match="RELEASE-[0-9].[0-9].[0-9]" --match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" --match="v[0-9].[0-9].[0-9]" --match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | awk -F- "{print \$$(NF-1)}"' || echo 0).$(shell git rev-parse --short=8 HEAD)
BUILD_NUMBER := $(shell bash -c ' \
set -o errexit -o pipefail -o xtrace; \
git rev-parse --is-inside-work-tree >/dev/null; \
output="$$(git describe \
--long \
--tags \
--match="RELEASE-[0-9].[0-9].[0-9]" \
--match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" \
--match="v[0-9].[0-9].[0-9]" \
--match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | \
awk -F- "{print \$$(NF-1)}" || \
echo 0)"; \
output+=".$$(git rev-parse --short=8 HEAD)"; \
echo "$$output"' || \
cat $(TC_DIR)/BUILD_NUMBER)
BUILD_ARCH := $(shell docker run --name=ciab-get-$(BASE_IMAGE)-$(RHEL_VERSION)-arch --rm $(BASE_IMAGE):$(RHEL_VERSION) rpm --eval %_arch )
TC_VERSION := $(shell cat "$(TC_DIR)/VERSION")
TOMCAT_VERSION := $(shell grep '^\s*TOMCAT_VERSION=' "$(TC_DIR)/traffic_router/build/build_rpm.sh" | cut -d= -f2)
Expand Down

0 comments on commit 13488f8

Please sign in to comment.