写两个包含不同环境参数的脚本config.dev.sh
和config.prod.sh
backend_git='backend-dev'
frontend_git='frontend-dev'
parser_port=5010
export backend_git frontend_git parser_git parser_port
backend_git='backend-prod'
frontend_git='frontend-prod'
parser_port=5040
export backend_git frontend_git parser_git parser_port
写一个处理逻辑的脚本,并在开始用source
引入对应的环境参数脚本
source "config.$1.sh"
echo "my backend repo is $backend_git"
echo "my frontend repo is $frontend_git"
echo "my parser port is $parser_port"
运行时将环境作为第一个参数传入
$ sh call.sh dev
my backend repo is backend-dev
my frontend repo is frontend-dev
my parser port is 5010
$ sh call.sh prod
my backend repo is backend-prod
my frontend repo is frontend-prod
my parser port is 5040
网友评论