Hi,
I'm not sure I'm following you ... or maybe we are using different ways to 
write our pipeline.
So, to be more explicit ... this is what we have in our pipeline:

pipeline {
triggers {
// runs every two hours
cron('H H/2 * * *')
}

That is a Multibranch project (to be precise we use GitHub, not sure if 
what I see maybe related to Git plugin itself) and what happens due to the 
"H" special case is that each branch will have a different starting hour 
and minutes that actually spread them over the time.
In that case you achieve the fact that there will never be two jobs 
starting at the same time.
Now, you can still have them overlap after they started.
To avoid that they run a certain stage at the same time we use locks:

steps {
// lock not usable in declarative pipeline due to JENKINS-43002
script { lock(label: resourceLabel, quantity: 1) {
With the above, what you achieve is that only and only one job at the time 
can run what's inside the script block.

We both cron and locks ... you spread your jobs across day hours and you 
are guaranteed that they run sequentially when the reach a part that can't 
be run by two jobs at the same time. And that works across branches.

On Wednesday, 1 April 2020 10:09:19 UTC+1, BCT Roel de Wildt wrote:
>
> Hi,
>
>  
>
> I have looked at it but it seems only possible if I change our Jenkinsfile 
> within each project stored in svn within the branches of it. And I can’t 
> see where to put the cron entry in the multi branch pipeline. I have only 
> the following options (… 12 hours, 1 day, 2 days, etc… ) in “Periodically 
> if not otherwise run” in the triggers section.
>
>  
>
> That means I can’t control the time it will be executed.
>
>  
>
> Alternative:
>
> I can execute a scheduled curl program which triggers the “trunk” 
> successfully, but the “branches/2019/trunk” gives a http 404 error.
>
>  
>
> Kind regards,
>
> Roel de Wildt
> Software Engineer
>
>  
>
> *Van:* jenkins...@googlegroups.com <javascript:> [mailto:
> jenkins...@googlegroups.com <javascript:>] *Namens *Gianluca
> *Verzonden:* woensdag 1 april 2020 09:17
> *Aan:* Jenkins Users <jenkins...@googlegroups.com <javascript:>>
> *Onderwerp:* Re: Command line acccess to build actions in muti branch 
> pipeline
>
>  
>
> Hi,
>
> we have a similar issue and we use a combination of trigger cron command 
> with "H" (if instead of * into cron syntax, you put "H" then Jenkins treats 
> it special)
>
> From documentation https://jenkins.io/doc/book/pipeline/syntax/
>
> "The H symbol can be thought of as a random value over a range, but it 
> actually is a hash of the job name, not a random function, so that the 
> value remains stable for any given project."
>
>  
>
> But also that's is not sufficient in cases the pipeline takes more than an 
> hour (as in our case), hence we add on top of this the usage of 
> LockableResources and we created a resource that we lock in the stages of 
> the pipeline we know we can't run at the same time because of constraints.
>
>  
>
> https://jenkins.io/doc/pipeline/steps/lockable-resources/
>
>  
>
> So, a combination of both ... does the tricks for us and I think it should 
> work as well for you too.
>
>  
>
> Cheers,
>
> Gianluca
>
>  
>
>
> On Wednesday, 1 April 2020 08:08:41 UTC+1, BCT Roel de Wildt wrote:
>
> Hello,
>
>  
>
> In previous versions of Jenkins LTS there was a jenkins-cli.jar which I 
> used to trigger a build job. Now with the latest (2.222.1) I can’t find how 
> to do the build jobs on a scheduled base. Where one is shedules at 19:00, 
> the other on 20:30, etc… They can’t run at same time due resources limits. 
> What is the best option to execute a single build job in a multi branch 
> pipeline?
>
>  
>
> Kind regards,
>
> Roel de Wildt
> Software Engineer
>
>  
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jenkins...@googlegroups.com <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/c96a2c92-9eb4-4e3e-9323-63c829418bc3%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/c96a2c92-9eb4-4e3e-9323-63c829418bc3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f880bc76-6669-401b-b1b4-b588e4c794df%40googlegroups.com.

Reply via email to