I am configuring CodePipeline using Elastic Beanstalk. Elastic Beanstalk has to deploy the war file in its Tomcat's webapps folder. But it is deploying the war file in webapps/ROOT folder. So I have created below script server-update.config in .ebextensions folder to copy the war file into webapps folder from webapps/ROOT/.
.ebextensions/server-update.config
container_commands:
copy_file:
command: sudo cp /var/lib/tomcat8/webapps/ROOT/test/* /var/lib/tomcat8/webapps/
leader_only: true
Above code is executed successfully. Below is the log.
[2016-04-18T14:06:30.939Z] INFO [1128] - [Application update code-pipeline-1460988338596-MyAppBuild-2d3bd0c0-62bc-4927-bd09-b04ba81e7c03@15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_SampleEB/Command copy_file] : Starting activity...
[2016-04-18T14:06:30.973Z] INFO [1128] - [Application update code-pipeline-1460988338596-MyAppBuild-2d3bd0c0-62bc-4927-bd09-b04ba81e7c03@15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_SampleEB/Command copy_file] : Completed activity.
But ElasticBeanstalk is cleaning the tomcat webapps folder after executed .ebextensions file(while running /opt/elasticbeanstalk/hooks/appdeploy/enact/02clean.sh internally)
+ EB_APP_DEPLOY_BASE_DIR=/var/lib/tomcat8/webapps
+ rm -rf /var/lib/tomcat8/webapps/ROOT /var/lib/tomcat8/webapps/sampleapp.war
I dont know how to configure my script to execute at last. Please anyone help me with above requirement.