Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
fun
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcc1212 committed Apr 5, 2024
1 parent c0b7eaa commit 13da9d0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pipeline {
SSH_KEY = credentials('nial-ssh-aws') // Credential ID for SSH private key
REMOTE_USER = 'ubuntu' // User to SSH into the EC2 instance
REMOTE_HOST = '13.49.230.240' // Public IP or hostname of your EC2 instance
REMOTE_DIR = '/var/www/html/react-app' // Directory on the EC2 instance to deploy the app
REACT_APP_BUILD_DIR = 'build' // Build directory of your React app
}
stages {
stage('Install') {
Expand Down Expand Up @@ -45,20 +43,20 @@ pipeline {
}
}
}
stage ('Deploy') {
stage('Remote git pull') {
steps {
script {
sshagent(['nial-ssh-creds']) {
sh "scp -i ${SSH_KEY} -r ${REACT_APP_BUILD_DIR} ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_DIR}"
sh "ssh -i ${SSH_KEY} ${REMOTE_USER}@${REMOTE_HOST} 'cd TSI && git pull'"
}
}
}
}
stage('Restart Server') {
stage('Deploy') {
steps {
script {
sshagent(['nial-ssh-creds']) {
sh "ssh -i ${SSH_KEY} ${REMOTE_USER}@${REMOTE_HOST} 'sudo systemctl restart nginx'"
sh "ssh -i ${SSH_KEY} ${REMOTE_USER}@${REMOTE_HOST} 'screen && cd TSI/next/news-aggregation && npm run dev'"
}
}
}
Expand Down

0 comments on commit 13da9d0

Please sign in to comment.