ci: run the nightly test only on the main branch

Currently, all PRs trigger the daily nightly testing. Let's limit that to just
the main branch.

I found this here:
https://stackoverflow.com/questions/39168861/build-periodically-with-a-multi-branch-pipeline-in-jenkins

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2021-02-15 09:09:22 +01:00 committed by Alexander Todorov
parent 8760de26de
commit 2b823b97ad

View file

@ -1,8 +1,10 @@
var cron_string = BRANCH_NAME == "main" ? "@daily" : ""
pipeline {
agent none
triggers {
cron('@daily')
cron(cron_string)
}
environment {
@ -816,7 +818,7 @@ void preserve_logs(test_slug) {
void detect_build_cause() {
def buildCause = currentBuild.getBuildCauses().get(0)
if ( buildCause.shortDescription == 'Started by timer') {
if ( buildCause.shortDescription == 'Started by timer' && env.BRANCH_NAME == 'main') {
return "cron"
}