0

I am using jenkins CI to build my project. After the build I had post steps shell script copy the war to WSO2 application servers /repository/deployment/server/webapps/ folder. But what I observed was sometimes ( not always ), the server failed to redeploy the web application. Most of the times the web application would be redeployed using the new war file copied by jenkins into the webapps folder. But sometimes this did not happen. At such times the only solution was to stop the wso2as server, delete the web applications folder leaving only the new war file in wenapps directory and start the wso2as server again. This deployed the new war file and testing could proceed.

But we need to run automated selenium tests. So for the tests to run we need the new war file to be deployed reliably on every jenkins build.

So I wrote a little script in the jenkins post step like below :

    #!/bin/bash
/home/kk/wso2as-5.0.1/bin/wso2server.sh stop &&
sleep 1m &&
rm -rf /home/kk/wso2as-5.0.1/repository/deployment/server/webapps/Duster_App1* &&
cp /home/kk/.jenkins/workspace/Dusters_App1/target/Duster_App1-${MAVEN_VERSION}.war /home/kk/wso2as-5.0.1/repository/deployment/server/webapps/Duster_App1.war &&
/home/kk/wso2as-5.0.1/bin/wso2server.sh start &&
echo Starting wso2as

This script runs. The wso2as server is stopped, the webapp folder is deleted, the new war file is copied corectly in place, I get the 'Starting wso2as' message on jenkins console output, BUT the wso2as server does not start. It remains in the stopped state. I introduced the sleep 1m line after the wso2server.sh stop command thinking the server may be taking time to shut down and hence fails to start again by the time the wso2server.sh start command is run. But no. The server is stopped cleanly before the start command is run as I have verified by following the log file as well as by ps aux command.

So what could be preventing the server from starting again?

4

2 回答 2

1

IMO writing a script to delete webapp folder and restart the server from time to time would not be a good idea. I would suggest you to do following steps and then try the deployment from your jenkins build server to AppServer repository/deployment/server/webapps.

1.) Stop the server 2.) Open the [AS_HOME]/repository/conf/tomcat/catalina-server.xml config file 3.) Now make the unpackWARs attribute in Host element "false" 4.) restart the server

By default AppServer would extract the WAR file inside webapps, and it is possible that this could cause intermittent issues when deploying the same webapp again and again. Please try this way and see.

于 2013-08-28T08:08:34.837 回答
0

The WSO2 servers are OSGI based. The modules offer also web services for all tasks you can do in the admin console. If you start the server as ./wso2server.sh -DosgiConsole and you can list all service interaces with osgi> listAdminServices. You will find i.e. interfaces to upload WAR, CAR and AAR archives. The upload is one stateless call, but the handling of the artifact upload is a little bit tricky and you have also to deal with the self signed certificates of the WSO2 server. You can do the upload in a script language of your choice or make a simple Jenkins plugin and integrate this into your build job.

If you want comfort and don't do it yourself, use this Jenkins post-build plug-in to deploy the WAR into the WSO2 AS via the deployment web service API: https://github.com/ma-ha/Jenkins-WSO2AS-Deployer

于 2014-06-16T14:12:46.233 回答