I have an auto scaling group which associate with my code-pipeline so when there's a changes from my git project and it will auto deploy. So now I want my code-pipeline to skip event on Beforeinstall and Afterinstall for existing instance/second build while when there's new instance launched by auto scaling group, it will rerun all the scripts on my appspec.yml file. Sorry I'm new.. please prove me any solutions for this..
I have tried to create a file during my code deployment and write the scripts to check if the file exist, skip the deployment. but it will echo out message like " file exist, skipping deployment" but when I went to check the log , it still run all the scripts.
Below are my scripts for skipping second build
if [ -e /path/to/second_build_indicator.txt ]; then
echo "file exist. Skipping deployment."
exit 0
fi
This is my appspec.yml file
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