Declarative pipeline syntax: how to configure blockOn and waiting for a time slot to start?

606 views
Skip to first unread message

Amedee Van Gasse

unread,
Mar 10, 2019, 11:40:26 AM3/10/19
to Jenkins Users
I have a Bitbucket Server Project.

I am using declarative Jenkinsfiles

All branches/PRs of all repos in the Project are built if they have a Jenkinsfile. Wonderful.
The branches/PRs are built when there is new git activity. Wonderful.


There is one repo with 2 requirements that I'm stuck on:

1. It cannot run when anything else is running, not even other branches of itself. I already have disableConcurrentBuilds() but then I can still run different branches in parallel and I don't want that. I know about the Build Blocker plugin and I would put this in my Jenkinsfile, but I don't know where to put it:

    blockOn('.*') {
        blockLevel('GLOBAL')
        scanQueueFor('ALL')
    }

2. That particular job, any branch of it, is only allowed to start between specific hours, regardless of how it got triggered. I don't know how to put that in my Jenkinsfile. I looked at quietPeriod and rateLimitBuilds, but they seem to be for something else.


I had a third question about how to schedule it with cron, but I found that myself already:

triggers {
cron('H H(0-6) * * 1-5')
}

meaning anywhere between midnight and 6 AM on work days.

Amedee Van Gasse

unread,
Mar 10, 2019, 12:06:11 PM3/10/19
to Jenkins Users
Can I do item 1 with lockable resources? But then wouldn't every Jenkinsfile in all of my repos require lockable resources? So I think that's also not the way to go but I could be wrong.
Reply all
Reply to author
Forward
0 new messages