diff --git a/Jenkinsfile b/Jenkinsfile index a825e72..1962f71 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ pipeline { agent { label 'linux' } + triggers { + cron('H 0 12,0 * * *') + } stages { stage('Checkout') { when { @@ -21,8 +24,10 @@ pipeline { } steps { script { - // Replace 'Jenkins' with the name Jenkins uses to commit - if (sh(script: 'git log -1 --pretty=format:"%an"', returnStdout: true).trim() == 'Jenkins') { + def causedByScmEvent = currentBuild.rawBuild.getCause(hudson.triggers.SCMTrigger.SCMTriggerCause) + 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' error('Last commit was by Jenkins, skipping build') } else {