0
votes

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?

1

1 Answers

2
votes

I have been using curl statements in my jenkins pipeline jobs for quit some time as we have load balancers on our prod environment so we need to start stop multiple times which was not supported by Deploy plugin. So, instead we use curl statements for tomcat deployment. You can give it a try:

curl --upload-file <file_path> -u <username>:<password>  "http://<URL>:<port>/manager/text/deploy?path=/<context>&update=true"

here username and password are credentials of script manager of tomcat. update = true takes care of redployment. I do not think that it deletes the context.xml