Skip to content

Commit c52b3f9

Browse files
committed
Use ansible.env file in lieu of ci.env if available
1 parent bb59907 commit c52b3f9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/common.Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ $(if $(shell wc -l $(REPO_BASE_DIR)/.config.location | grep 1),,$(error The .con
2626
DEPLOYMENT_FQDN := $(notdir $(patsubst %/,%, $(dir $(REPO_CONFIG_LOCATION))))
2727
# Construct CI_ENV_FILE using Make functions
2828
CI_ENV_FILE := $(realpath $(dir $(REPO_CONFIG_LOCATION))/../../.gitlab/pipelines/1_configurations/$(DEPLOYMENT_FQDN)/ci.env)
29-
$(if $(CI_ENV_FILE),,$(error The location of the repo.config file given in .config.location is invalid. Cannot find the ci.env file. Aborting))
30-
$(if $(shell cat $(CI_ENV_FILE)),,$(error The location of the repo.config file given in .config.location is invalid. Cannot find the ci.env file. Aborting))
29+
# Check if ci.env exists and is not empty
30+
ifeq ($(shell [ -e $(CI_ENV_FILE) ] && cat $(CI_ENV_FILE)),)
31+
# If ci.env does not exist, check for ansible.env
32+
ANSIBLE_ENV_FILE := $(REPO_CONFIG_LOCATION)/ansible.env
33+
ifeq ($(shell [ -e $(ANSIBLE_ENV_FILE) ] && cat $(ANSIBLE_ENV_FILE)),)
34+
$(error Neither the ci.env file nor the ansible.env file could be found. Aborting.)
35+
else
36+
$(warning ci.env file is missing. Falling back to ansible.env file. We assume that you are running in a CI pipeline.)
37+
CI_ENV_FILE := $(ANSIBLE_ENV_FILE)
38+
endif
39+
endif
3140

41+
# Use SELECTED_ENV_FILE in your targets as needed
3242
ifeq ($(_yq),)
3343
_yq = docker run --rm -i -v $${PWD}:/workdir mikefarah/yq:4.30.4
3444
endif

0 commit comments

Comments
 (0)