In this article, I will be sharing, basic deployment steps for Java applications, i.e, war files to servers like tomcat, JBoss, WebLogic, or WebSphere.
Deployments steps:
1) Download or Copy war file into deployment server stage location.
2) Stop the service (eg: Jboss service)
3) Take a backup of present war which is already deployed.
4) Copy new war file from stage location to the deployment location.
5) Start the stopped application service. (eg: JBoss Service)
Here I will be explaining in a windows environment, with the help of PowerShell we will be deploying the war file in server.
Deployments steps:
1) Download or Copy war file into deployment server stage location.
2) Stop the service (eg: Jboss service)
3) Take a backup of present war which is already deployed.
4) Copy new war file from stage location to the deployment location.
5) Start the stopped application service. (eg: JBoss Service)
Here I will be explaining in a windows environment, with the help of PowerShell we will be deploying the war file in server.
Set-ExecutionPolicy Unrestricted echo " Deploying ${ENV:Rel_Num} " $ErrorActionPreference = 'Stop' copy /source/test.war /location/stage stop-service application-service copy location\deployments\folder\*.war \location\backup\ Remove-item location/of/deployments/folder/* -recurse copy /location/stage\test.war location\deployments\folder start-service application-service
Powershell script to check the status of URL / website is up or not after deployment :-
Generally, after deployment, the website does not come up immediately. It takes 30 seconds to 3 mins or even more sometimes. So, here, I have written the PowerShell script to check whether the status of URL or website has come up or not. This below script can be executed after the deployment is successful.
Write-Host "Please wait as site is coming up..." -foregroundcolor blue Write-Host "If it is taking more than 5 mins, please check manually!!" -foregroundcolor blue Do { Try{ $HTTP_Request = [System.Net.WebRequest]::Create('http://192.168.00.00:8080/test') $HTTP_Response = $HTTP_Request.GetResponse() $HTTP_Status = [int]$HTTP_Response.StatusCode Write-Host $HTTP_Status If ($HTTP_Status -eq 200) { Write-Host "Site is UP!!" -foregroundcolor green } $HTTP_Response.Close() } Catch{ } } while ($HTTP_Status -ne 200)
Jenkins Plugin to Run Power shell script
To run power shell script from Jenkins, we need to install a plugin called PowerShell Plugin .