From 996ed01bbb4ff338e39e409d7727c1e10442439f Mon Sep 17 00:00:00 2001 From: charles Date: Sat, 28 Dec 2024 17:23:42 -0500 Subject: [PATCH] commit --- Jenkinsfile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..575a5c3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,39 @@ +pipeline { + agent any + environment { + SSH_CRED = credentials('server-key') + def CONNECT = 'ssh -o StrictHostKeyChecking=no ubuntu@3.96.221.187' + } + stages { + + stage('Build') { + steps { + echo 'building app' + sh "pwd" + sh "ls" + sh "zip -r webapp.zip ." + sh "ls" + } + } + + stage('Deploy') { + steps { + echo 'Deploying app' + sshagent(['server-key']) { + sh 'scp -o StrictHostKeyChecking=no -i $SSH_CRED webapp.zip ubuntu@3.96.221.187:/home/ubuntu' + sh '$CONNECT "sudo apt install zip -y"' + sh '$CONNECT "sudo rm -rf /var/www/html/"' + sh '$CONNECT "sudo mkdir /var/www/html/"' + sh '$CONNECT "sudo unzip webapp.zip -d /var/www/html/"' + } + } + } + + stage('Clean-Up') { + steps { + echo 'Remove existing files' + deleteDir() + } + } + } +} \ No newline at end of file