Step1: reach to project directory where pom.xml file exist from terminal
Step2: clean mavan using below
mvn clean
Step3: create a war file
mvn package
Step4: remove existing war from webapps tomcat
ssh user@address 'rm /data/apache-tomcat-8.0.29/webapps/warFile'
Step5: remove module exist in webapps tomcat
ssh user@address 'rm -rf moduleName'
Step6: copy war file to wenapps tomcat to remote server
scp /pathOf local dirctory/project.war user@address:/data/apache-tomcat-8.0.29/webapps
echo "deployment done"!
we need to provide some write permission to remote server webapps folder using below:
step1: need to login remote server in teminal
step2: move to directory where you want to provide write access
step3: chmod -R 777 .
we also need to add our system public key to remote because it will not ask password during deployment:
cat ~/.ssh/id_rsa.pub | ssh user@address 'cat >> .ssh/authorized_keys'
complete script save into a file(deploywar.sh):
mvn clean
mvn package
ssh user@address 'rm /data/apache-tomcat-8.0.29/webapps/warFile'
ssh user@address 'rm -rf moduleName'
scp /pathOf local dirctory/project.war user@address:/data/apache-tomcat-8.0.29/webapps
echo "deployment done"!
execute below command from terminal from project location where pom.xml file exist:
/path where script file /deploywar.sh
No comments:
Post a Comment