我有一个与我的代码管道关联的自动缩放组,所以当我的 git 项目发生更改时,它会自动部署。所以现在我希望我的代码管道为现有实例/第二个构建跳过 Beforeinstall 和 Afterinstall 上的事件,而当自动缩放组启动新实例时,它将重新运行我的 appspec.yml 文件中的所有脚本。对不起,我是新来的..请向我证明任何解决方案..
我尝试在代码部署期间创建一个文件并编写脚本来检查文件是否存在,跳过部署。但它会回显“文件存在,跳过部署”之类的消息,但是当我去检查日志时,它仍然运行所有脚本。
下面是我跳过第二次构建的脚本
if [ -e /path/to/second_build_indicator.txt ]; then
echo "file exist. Skipping deployment."
exit 0
fi
这是我的appspec.yml文件
version: 0.0
os: linux
hooks:
BeforeInstall:
- location: scripts/check_flag
timeout: 50
runas: root
ignoreApplicationStopFailures: true
- location:scripts/install_dependencies
timeout: 50
runas: root
AfterInstall:
- location: scripts/start_server
timeout: 50
runas: root