Add Cron Trigger to Pipeline
Some checks failed
andreas-personal/AndysAdguardHomeBlockList/pipeline/head There was a failure building this commit
Some checks failed
andreas-personal/AndysAdguardHomeBlockList/pipeline/head There was a failure building this commit
This commit is contained in:
parent
1b1264fcad
commit
b0a5af4cf1
9
Jenkinsfile
vendored
9
Jenkinsfile
vendored
@ -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 {
|
||||||
|
Reference in New Issue
Block a user