From ddab61a498fd0f68d518b87d6a2b3904cf5aa60d Mon Sep 17 00:00:00 2001 From: Sagar V S Date: Thu, 16 Jul 2020 22:16:55 -0500 Subject: [PATCH] Jenkinsfile --- Jenkinsfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..ffcc8e4f7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,47 @@ +pipeline{ + agent{ + label "node" + } + triggers { + cron 'H 20 * * *' + } + options { + timeout(time: 5, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuild() + } + stages{ + stage("Backup GitHub"){ + // Trigger only by timer and human, but not by Upstream or scm commit + when { + beforeAgent true + expression { BRANCH_NAME ==~ /(master|main)/ } + anyOf { + triggeredBy cause: 'UserIdCause' + triggeredBy cause: 'TimerTrigger' + } + } + steps{ + echo "========executing A========" + sh """ + ./bin/ghe-backup -v | tee backup${BUILD_NUMBER}.log + grep -q "Completed backup" backup${BUILD_NUMBER}.log || exit 1 + """ + } + } + } + post{ + failure { + echo "========email========" + mail to: 'vs.sagar@gmail.com' + subject: "GitHub Daily backup Failed: ${currentBuild.fullDisplayName}", + body: "This is important, can you please check and bring it to team's notice? ${env.BUILD_URL}" + } + success{ + echo "========pipeline executed successfully ========" + } + failure{ + echo "========pipeline execution failed========" + } + } +} \ No newline at end of file