Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}