I want to deploy war file using pipeline. What is the correct way to do it . Is there any way to use Deploy to container in pipeline code. The problem with calling catalina.sh o
In tomcat, there are two options to deploy a war:
Here some approaches to deploy a war and get the deployment status (success|failure)
You can put one of the following snippets in the deploy stage of your pipeline or migrate to groovy.
This is an endpoint which allow us to upload war from remote host to the tomcat server and as response:
OK - Deployed application at context path /foo
FAIL - Deployed application
at context path /my_app
but context failed to start
So, in order to detect is everything is ok, I perform this validation:
CURL_RESPONSE=$(curl -v -u $TOMCAT_USER:$TOMCAT_PASSWORD -T $WAR_PATH "http://$TOMCAT_HOST:$TOMCAT_PORT/manager/text/deploy?path=/$CONTEX_NAME&update=true")
if [[ $CURL_RESPONSE == *"FAIL"* ]]; then
echo "war deployment failed"
exit 1
else
echo "war deployed successfully "
exit 0
fi
Here you can find the required configurations to enable this endpoint :
After to copy war file to webapps, you can list the deployed apps, and find the name of your application in the http body response:
OK - Listed applications for virtual host localhost
/manager:running:0:manager
/:running:0:ROOT
/docs:running:0:docs
/examples:running:0:examples
/host-manager:running:0:host-manager
/my_app:running:0:my_app
/my_other_app:running:0:my_other_app
You can use a loop with a break as maximum attempts.
Here you can find the required configurations to enable this endpoint :
This is more clean and As I know, several monitoring platforms use this strategy.
All consist in expose an extra http endpoint in your application (web app, api rest ,daemon, etc)
This endpoint must return one of the following responses:
http stasus
xml or json
{
"status":"200",
"database_connectivity":"200",
"read_write_disk":"200",
"etc":"etc"
}
Finally you can use a loop to consume this /health endpoint from your Jenkins pipeline. This strategy will allow you to monitoring your apps from external platforms like:
i think the best way shoul be the deploy plugin https://www.jdev.it/deploying-your-war-file-from-jenkins-to-tomcat
In tomcat, configuration with jenkins and tomcat:
Update the 'apache-tomcat-8.5.5\webapps\manager\META-INF\context.xlm file. uncomment the Value tag. and restart server
context.xml file
Before :
<Context antiResourceLocking="false" privileged="true">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192\.168\.0\.9|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
</Context>
After change :
<Context antiResourceLocking="false" privileged="true" >
</Context>
for auto deployment: go to 'apache-tomcat-8.5.5\conf\context.xml' and add antiResourceLocking="true" in 'Context' tag