Please follow below steps for deploying WARs into Tomcat that is setup on a different machine.
Pre-requistes:
1. install ssh agent plugin in Jenkins master.
2. create ssh-keys in by executing the below command:
ssh-keygen
make sure you copy ssh public keys in target node where tomcat server is running.
3. also make sure you give permission to upload the WAR in by following command:
sudo chown ubuntu:ubuntu /var/lib/tomcat8/webapps/
Deployment steps:
Step 1:
Go to Jenkins, Add credentials. Select SSH username with private key. enter source machine SSH private keys. enter username as jenkins or ubuntu. Click OK
step 2: Go to Jenkins, Credentials, now copy the ID of the entry you made.
Step 3: Go to Pipeline: use the above ID in deploy stage and also make sure you enter target server ip address.
node {
-------
stage ('Deploy') {
echo "deploying to DEV tomcat "
sshagent(['15a9ed22-6dcb-4916-8536-bde265de07e8']) {
sh 'scp -o StrictHostKeyChecking=no /var/lib/jenkins/workspace/$JOB_NAME/MyWebApp/target/MyWebApp.war ubuntu@server_ip:/var/lib/tomcat8/webapps'
}
}
}
Pre-requistes:
1. install ssh agent plugin in Jenkins master.
2. create ssh-keys in by executing the below command:
ssh-keygen
make sure you copy ssh public keys in target node where tomcat server is running.
3. also make sure you give permission to upload the WAR in by following command:
sudo chown ubuntu:ubuntu /var/lib/tomcat8/webapps/
Deployment steps:
Step 1:
Go to Jenkins, Add credentials. Select SSH username with private key. enter source machine SSH private keys. enter username as jenkins or ubuntu. Click OK
step 2: Go to Jenkins, Credentials, now copy the ID of the entry you made.
Step 3: Go to Pipeline: use the above ID in deploy stage and also make sure you enter target server ip address.
node {
-------
stage ('Deploy') {
echo "deploying to DEV tomcat "
sshagent(['15a9ed22-6dcb-4916-8536-bde265de07e8']) {
sh 'scp -o StrictHostKeyChecking=no /var/lib/jenkins/workspace/$JOB_NAME/MyWebApp/target/MyWebApp.war ubuntu@server_ip:/var/lib/tomcat8/webapps'
}
}
}
No comments:
Post a Comment