This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Jenkinsfile with SSH agent for secure deployment
- Loading branch information
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
} | ||
|
@@ -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'" | ||
} | ||
} | ||
} | ||
} | ||
|