makefile中的设置环境
settings environment in makefile
我正在尝试在 make 中导出一个环境变量,以便在下一行中使用。我按照这里的建议做 Setting environment variables in a makefile.
eks-apps:
export KUBECONFIG=$(CURDIR)/terraform/kubernetes/cluster/$(shell ls terraform/kubernetes/cluster/ | grep kubeconfig)
kubectl get all
但是它没有在 kubectl 命令中使用那个 kubeconfig。我错过了什么?
配方中的每一行都将在新的 shell 中执行。因此,您必须对所有命令使用一个 shell:
eks-apps:
( \
export KUBECONFIG=$(CURDIR)/terraform/kubernetes/cluster/$(shell ls terraform/kubernetes/cluster/ | grep kubeconfig); \
kubectl get all \
)
来自您链接到的答案:
Please note: this implies that setting shell variables and invoking shell commands such as cd that set a context local to each process will not affect the following lines in the recipe.2 If you want to use cd to affect the next statement, put both statements in a single recipe line
我正在尝试在 make 中导出一个环境变量,以便在下一行中使用。我按照这里的建议做 Setting environment variables in a makefile.
eks-apps:
export KUBECONFIG=$(CURDIR)/terraform/kubernetes/cluster/$(shell ls terraform/kubernetes/cluster/ | grep kubeconfig)
kubectl get all
但是它没有在 kubectl 命令中使用那个 kubeconfig。我错过了什么?
配方中的每一行都将在新的 shell 中执行。因此,您必须对所有命令使用一个 shell:
eks-apps:
( \
export KUBECONFIG=$(CURDIR)/terraform/kubernetes/cluster/$(shell ls terraform/kubernetes/cluster/ | grep kubeconfig); \
kubectl get all \
)
来自您链接到的答案:
Please note: this implies that setting shell variables and invoking shell commands such as cd that set a context local to each process will not affect the following lines in the recipe.2 If you want to use cd to affect the next statement, put both statements in a single recipe line