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

Commit

Permalink
Update Jenkinsfile with SSH agent for secure deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcc1212 committed Apr 5, 2024
1 parent a708ae5 commit c1b6266
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
nodejs "NodeJS"
}
environment {
SSH_KEY = credentials('nial-ssh-aws') // Credential ID for SSH private key
// 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
}
Expand Down Expand Up @@ -39,14 +39,18 @@ pipeline {
stage('Remote git pull') {
steps {
script {
sh "ssh -i ${SSH_KEY} [email protected] 'cd TSI && git pull'"
sshagent(['nial-ssh-creds']) {
sh "ssh [email protected] 'cd TSI && git pull'"
}
}
}
}
stage('Deploy') {
steps {
script {
sh "ssh -i ${SSH_KEY} [email protected] 'screen && cd TSI/next/news-aggregation && npm install && npm run dev'"
sshagent(['nial-ssh-creds']) {
sh "ssh [email protected] 'screen && cd TSI/next/news-aggregation && npm install && npm run dev'"
}
}
}
}
Expand Down

0 comments on commit c1b6266

Please sign in to comment.