I am using the Jenkins Deploy to container plugin to deploy my project to a local tomcat. According to Jenkins console output, the plugin redeploys, undeploys, then deploys as part of its process. During undeployment, tomcat deletes the $CATALINA_BASE/conf/[enginename]/[hostname]/[myprojectname].xml context file (aka $CATALINA_BASE/conf/Catalina/localhost/[myprojectname].xml) for reasons described here.
To the best of my knowledge, the answer to that question is not applicable when using the deploy plugin.
I am using this file to configure resources and putting it in /META-INF/context.xml is unfeasible as I need to be able to deploy to different contexts.
I have tried setting the file as read only which causes the Jenkins process to fail since it is unable to delete the file. Setting autoDeployment to false in server.xml also does not help.
This question is different from this one as in his case the file is renamed whereas mine is deleted.
How do I stop the plugin from deleting the context file? If I cannot, what alternative could be used?