diff --git a/Jenkinsfile b/Jenkinsfile index 234c300..6bde369 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -162,7 +162,7 @@ pipeline { subject: "[Jenkins] ${env.JOB_NAME} #${env.BUILD_NUMBER} failed", body: renderEmail('Build failed', '#dc2626', buildInfo()), mimeType: 'text/html', - to: 'admin@msigmagokulam.com, ashir@mgsigma.net' + to: 'admin@msigmagokulam.com, ashir@mgsigma.net, kailasdevdas@msigmagokulam.com' ) } } diff --git a/Jenkinsfile.prod b/Jenkinsfile.prod index 86deeaf..ccab6a6 100644 --- a/Jenkinsfile.prod +++ b/Jenkinsfile.prod @@ -89,7 +89,7 @@ pipeline { steps { sshagent (credentials: ["${env.SSH_CREDENTIALS_ID}"]) { sh """ - ssh -o StrictHostKeyChecking=no \$REMOTE_HOST 'mkdir -p \$REMOTE_DEPLOY_DIR' + ssh -o StrictHostKeyChecking=no $REMOTE_HOST 'mkdir -p $REMOTE_DEPLOY_DIR' rsync -az --delete \\ --exclude='.git/' \\ --exclude='node_modules/' \\ @@ -97,7 +97,7 @@ pipeline { --exclude='frontend/node_modules/' \\ --exclude='frontend/dist/' \\ -e "ssh -o StrictHostKeyChecking=no" \\ - ./ \$REMOTE_HOST:\$REMOTE_DEPLOY_DIR/ + ./ $REMOTE_HOST:$REMOTE_DEPLOY_DIR/ """ } } @@ -107,9 +107,9 @@ pipeline { steps { sshagent (credentials: ["${env.SSH_CREDENTIALS_ID}"]) { sh """ - ssh -o StrictHostKeyChecking=no \$REMOTE_HOST ' + ssh -o StrictHostKeyChecking=no $REMOTE_HOST ' set -e - cd \$REMOTE_DEPLOY_DIR + cd $REMOTE_DEPLOY_DIR if [ -n "\$(docker compose -f $COMPOSE_FILE ps -q 2>/dev/null)" ]; then echo "[INFO] Stopping existing containers..." @@ -130,96 +130,91 @@ pipeline { } post { + always { + script { + env.BUILD_INFO_HASH = sh( + script: "git rev-parse --short HEAD 2>/dev/null || echo N/A", + returnStdout: true + ).trim() + env.BUILD_INFO_AUTHOR = sh( + script: "git log -1 --pretty=format:'%an' 2>/dev/null || echo N/A", + returnStdout: true + ).trim() + env.BUILD_INFO_MESSAGE = sh( + script: "git log -1 --pretty=format:'%s' 2>/dev/null || echo 'No commit message found'", + returnStdout: true + ).trim() + + def cause = currentBuild.getBuildCauses()?.getAt(0)?.shortDescription ?: 'Unknown' + env.BUILD_INFO_TRIGGER = cause.contains('Started by user') ? 'Manual trigger' : cause + } + } success { script { - def causes = currentBuild.getBuildCauses() - def triggeredBy = causes ? causes[0].shortDescription : "Unknown" - def isManual = triggeredBy.contains('Started by user') - - def commitHash = sh(script: "git rev-parse --short HEAD", returnStatus: true) == 0 ? - sh(script: "git rev-parse --short HEAD", returnStdout: true).trim() : "N/A" - def commitAuthor = sh(script: "git log -1 --pretty=format:%an", returnStatus: true) == 0 ? - sh(script: "git log -1 --pretty=format:%an", returnStdout: true).trim() : "N/A" - def commitMessage = sh(script: "git log -1 --pretty=format:%s", returnStatus: true) == 0 ? - sh(script: "git log -1 --pretty=format:%s", returnStdout: true).trim() : "No commit message found" - - def envInfo = """ -
Commit Info:
-Review the output here:
-- View Build Log -
-Production deployment via Jenkins. Contact DevOps for any issues.
-Commit Info:
-Review error logs here:
-- View Build Log -
-Production deployment via Jenkins. Contact DevOps for any issues.
-| + + |