Skip to content

Commit 86d79d5

Browse files
Jenkinsfile: do not trigger integ tests if timer triggered.
1 parent d6443b7 commit 86d79d5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Jenkinsfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def signingArgs = '-PsigningKeyFile=$SIGNING_FILE -PsigningKeyId=$SIGNING_ID -Ps
1111
def gitlabRepoArgs = '-PgitlabUrl=$GITLAB_URL -PgitlabPrivateToken=$GITLAB_TOKEN'
1212
def uploadRepoArgsCentral = '-PsonatypeUsername=$OSSRH_LOGIN_USR -PsonatypePassword=$OSSRH_LOGIN_PSW'
1313

14+
boolean startedByTimer = currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').size() > 0
15+
def buildCauses = currentBuild.getBuildCauses()
16+
echo "startedByTimer=$startedByTimer, build causes: $buildCauses"
17+
1418
// https://jenkins.io/doc/book/pipeline/syntax/
1519
pipeline {
1620
agent { label 'java' }
@@ -146,11 +150,17 @@ pipeline {
146150

147151
success {
148152
updateGitlabCommitStatus name: 'build', state: 'success'
149-
// Trigger integration tests in GitLab
150-
// URL configured like <host>/api/v4/projects/<id>/trigger/pipeline?token=<token>
151-
// Note: do not fail on error in case ref does not exist, only output response
152-
// --silent --show-error disable progress output but still show errors
153-
sh 'curl --silent --show-error -X POST "$GITLAB_INTEG_TESTS_TRIGGER_URL&ref=$GIT_BRANCH"'
153+
script {
154+
if (startedByTimer) {
155+
echo "Started by timer, not triggering integration tests"
156+
} else {
157+
// Trigger integration tests in GitLab
158+
// URL configured like <host>/api/v4/projects/<id>/trigger/pipeline?token=<token>
159+
// Note: do not fail on error in case ref does not exist, only output response
160+
// --silent --show-error disable progress output but still show errors
161+
sh 'curl --silent --show-error -X POST "$GITLAB_INTEG_TESTS_TRIGGER_URL&ref=$GIT_BRANCH"'
162+
}
163+
}
154164
}
155165
}
156166
}

0 commit comments

Comments
 (0)