Add Cron Trigger to Pipeline
Some checks failed
andreas-personal/AndysAdguardHomeBlockList/pipeline/head There was a failure building this commit

This commit is contained in:
Andreas Fahrecker 2024-04-10 18:50:30 +02:00
parent 1b1264fcad
commit b0a5af4cf1

9
Jenkinsfile vendored
View File

@ -4,6 +4,9 @@ pipeline {
agent { agent {
label 'linux' label 'linux'
} }
triggers {
cron('H 0 12,0 * * *')
}
stages { stages {
stage('Checkout') { stage('Checkout') {
when { when {
@ -21,8 +24,10 @@ pipeline {
} }
steps { steps {
script { script {
// Replace 'Jenkins' with the name Jenkins uses to commit def causedByScmEvent = currentBuild.rawBuild.getCause(hudson.triggers.SCMTrigger.SCMTriggerCause)
if (sh(script: 'git log -1 --pretty=format:"%an"', returnStdout: true).trim() == 'Jenkins') { if (causedByScmEvent == null) {
echo 'Not triggered by SCM, continuing build'
} else if (sh(script: 'git log -1 --pretty=format:"%an"', returnStdout: true).trim() == 'Jenkins') {
currentBuild.result = 'ABORTED' currentBuild.result = 'ABORTED'
error('Last commit was by Jenkins, skipping build') error('Last commit was by Jenkins, skipping build')
} else { } else {