mirror of
https://github.com/Ichitux/lambada-fiesta-live.git
synced 2026-05-15 17:32:21 +02:00
Modified jenkinsfile
This commit is contained in:
33
Jenkinsfile
vendored
33
Jenkinsfile
vendored
@@ -6,11 +6,10 @@ pipeline {
|
||||
REMOTE_DIR = '/home/zouklambadabcn.com/public_html'
|
||||
PM2_APP = 'ZLB'
|
||||
// Name of Jenkins Credentials (Username with private key) to SSH
|
||||
SSH_CREDS = 'ssh-remote' // <-- configure this in Jenkins Credentials
|
||||
SSH_CREDS = 'root_ssh' // <-- configure this in Jenkins Credentials
|
||||
}
|
||||
|
||||
options {
|
||||
ansiColor('xterm')
|
||||
timestamps()
|
||||
}
|
||||
|
||||
@@ -22,32 +21,12 @@ pipeline {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: env.SSH_CREDS, keyFileVariable: 'SSH_KEY', usernameVariable: 'SSH_USER')]) {
|
||||
// Build the remote command to run
|
||||
def remoteCmd = """
|
||||
set -euo pipefail
|
||||
set -e
|
||||
cd "${env.REMOTE_DIR}"
|
||||
echo "[$(date)] PWD=$(pwd) on ${HOSTNAME}"
|
||||
|
||||
# Ensure repo is cleanly updated
|
||||
git fetch --all --prune
|
||||
git reset --hard HEAD
|
||||
git pull --rebase --autostash || git pull
|
||||
|
||||
# Use npm if available, fallback to npx if needed
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
npm ci || npm install
|
||||
npm run build
|
||||
else
|
||||
npx --yes npm@latest ci || npx --yes npm@latest install
|
||||
npx --yes npm@latest run build
|
||||
fi
|
||||
|
||||
# Restart pm2 app
|
||||
if command -v pm2 >/dev/null 2>&1; then
|
||||
pm2 restart "${PM2_APP}" || pm2 start npm --name "${PM2_APP}" -- run start
|
||||
pm2 save || true
|
||||
else
|
||||
echo 'pm2 not found in PATH' >&2
|
||||
exit 1
|
||||
fi
|
||||
git pull
|
||||
npm install
|
||||
npm run build
|
||||
pm2 restart ${env.PM2_APP}
|
||||
""".stripIndent()
|
||||
|
||||
// SSH options for non-interactive, secure connection
|
||||
|
||||
Reference in New Issue
Block a user