我有一个我的应用程序的流程,我有一个名为Staging的实例,另一个是QA,然后有一个Production实例。我们从Staging创建分支,一旦验证,它们然后合并到分段,然后合并到QA,然后在完成验证后合并到主分区。我是管道新手,我想实现以下流程
我正在使用Bitbucket与AWS CodeDeploy服务和存储库托管在Bitbucket上目前我能够在1个实例上部署主分支。我怎样才能做到这一点?我的appspec.yml如下
image: php:7.2.13
pipelines:
branches:
master:
- step:
caches:
- composer
script:
- sh bitbucket-pipelines-common.sh
- vendor/bin/phpunit
- sh bitbucket-pipelines-codedeploy.sh
develop:
- step:
caches:
- composer
script:
- sh bitbucket-pipelines-common.sh
- vendor/bin/phpunit
custom:
just-test-without-cache:
- step:
script:
- sh bitbucket-pipelines-common.sh
- vendor/bin/phpunit
如果代码部署脚本从环境中提取AWS变量,则可以创建一个bash脚本,以便在该步骤之前运行,该脚本根据分支设置环境变量,即
#!/bin/bash
if [ "$BITBUCKET_BRANCH" = "master" ]
then
export APPLICATION_NAME="..."
export DEPLOYMENT_CONFIG="..."
export DEPLOYMENT_GROUP_NAME="Development"
export S3_BUCKET=""..."
elif [ "$BITBUCKET_BRANCH" = "staging" ]
then
export APPLICATION_NAME="..."
export DEPLOYMENT_CONFIG="..."
export DEPLOYMENT_GROUP_NAME="Staging"
export S3_BUCKET=""..."
elif [ "$BITBUCKET_BRANCH" = "production" ]
then
export APPLICATION_NAME="..."
export DEPLOYMENT_CONFIG="..."
export DEPLOYMENT_GROUP_NAME="Production"
export S3_BUCKET=""..."
fi