Skip to content

Instantly share code, notes, and snippets.

@Lh4cKg
Last active August 6, 2025 05:59
Show Gist options
  • Select an option

  • Save Lh4cKg/055e133802a2369118f545a8c546b4d0 to your computer and use it in GitHub Desktop.

Select an option

Save Lh4cKg/055e133802a2369118f545a8c546b4d0 to your computer and use it in GitHub Desktop.
Jenkins Pipeline Configuration
// Pipeline For Specified Agent Node
pipeline {
agent { label 'Scheduler Agent Node' }
parameters {
string(name: 'cache', defaultValue: 'cache-buster-req', description: 'Enter the cache buster and build.')
}
stages {
stage('Update and Build on Local Agent') {
steps {
script {
echo "Running build on agent for parameter: ${params.cache}"
dir('/home/dwhadmin/projects/dg_scheduler') {
sh "git pull -f ssh://[email protected]/dailygroupgeorgia/dg_scheduler.git"
sh "bash scripts/build.sh -cache '${params.cache}'"
}
echo "Build script executed successfully."
}
}
}
}
post {
success {
echo "Pipeline finished successfully."
}
failure {
echo "Pipeline failed. Please check the console output for errors."
}
}
}
// Pipeline For Built in Node
pipeline {
// This pipeline can run on any available Jenkins agent.
agent any
parameters {
string(name: 'cache', defaultValue: 'cache-buster-req', description: 'Enter the cache buster and build.')
}
// Environment variables can be defined here if needed.
environment {
REMOTE_SERVER_IP = '192.168.129.96'
}
stages {
stage('Connect, Update, and Build on Remote Server') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'airflow-ssh-up-creds', usernameVariable: 'SSH_USER', passwordVariable: 'SSHPASS')]) {
echo "Connecting to remote server as user: ${env.SSH_USER} -echo- ${params.cache}"
// For Builtin Node
sh """
sshpass -e ssh -o StrictHostKeyChecking=no '$SSH_USER'@'$REMOTE_SERVER_IP' "cd /home/dwhadmin/projects/dg_scheduler && git pull -f ssh://[email protected]/dailygroupgeorgia/dg_scheduler.git && bash scripts/build.sh -cache '${params.cache}'"
"""
echo "Build script executed successfully on remote server."
}
}
}
}
}
// The post section runs after all stages are completed.
post {
success {
echo "Pipeline finished successfully."
// You could add success notifications here (e.g., email, Slack).
}
failure {
echo "Pipeline failed. Please check the console output for errors."
// You could add failure notifications here.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment