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:
meaning anywhere between midnight and 6 AM on work days.