How to trigger a job at a certain time in Jenkins pipeline?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to trigger a job at a certain time in Jenkins pipeline?

ZillaYT
I see this, but I don't understand how to implement it for my use case.
https://www.codependentcodr.com/scheduled-builds-in-jenkins-scripted-pipelines.html

I want JobA to trigger JobB, but at a certain time. I do this now

Step in JobA to trigger JobB
build job: JobB,
      wait: true

...but I wish I can do this (for illustration only, the cron option does not exist of course)

Step in JobA to trigger JobB to run around 9:00pm ET
build job: JobB,
      cron: "H 21 * * 1",
      wait: true

Any ideas? Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/332c73a3-cac2-4192-bb97-b39640207ff3n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

Gianluca
From what I know that's specific thing is not possible.
And to be honest, it's quite strange as well.

Maybe if you explain us why are you trying to do that, we could suggest alternatives that are possible in Jenkins.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 [hidden email] ha scritto:
I see this, but I don't understand how to implement it for my use case.

I want JobA to trigger JobB, but at a certain time. I do this now

Step in JobA to trigger JobB
build job: JobB,
      wait: true

...but I wish I can do this (for illustration only, the cron option does not exist of course)

Step in JobA to trigger JobB to run around 9:00pm ET
build job: JobB,
      cron: "H 21 * * 1",
      wait: true

Any ideas? Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/26e5a780-5c25-4a5d-859a-d0133b07e3b2n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

Fabi

>...but I wish I can do this (for illustration only, the cron option does not exist of course)
>
>Step in JobA to trigger JobB to run around 9:00pm ET
>build job: JobB,
>      cron: "H 21 * * 1",
>      wait: true

How about JobB always runs at 9 (started from cron)
and always checks first, whether it should be executed
or not. JobA would set a "flag" or variable or whatever
to let JobB know that it should go on, once it's been
started.

bye  Fabi

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20200915145620.90F0E4213390%40macserver.private.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

ZillaYT
In reply to this post by Gianluca
Thanks for responding Gianluca.

So I have a Jenkins job that builds production code mid-day, but does NOT deploy it. We have a a separate deployment job that's cron'ed at "H 21 * * 1" to deploy the code built by the mid-day build job

Part of the mid-day build is to check if certain microservices' versions need to be deployed to production as well, and I'd like for it to trigger a job for each microservice it needs to deploy at "H/30 20 * * 1". IOW the needed microservices can not be deployed mid-day either.

Hope that explains it.
On Tuesday, September 15, 2020 at 10:47:34 AM UTC-4 Gianluca wrote:
From what I know that's specific thing is not possible.
And to be honest, it's quite strange as well.

Maybe if you explain us why are you trying to do that, we could suggest alternatives that are possible in Jenkins.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 [hidden email] ha scritto:
I see this, but I don't understand how to implement it for my use case.

I want JobA to trigger JobB, but at a certain time. I do this now

Step in JobA to trigger JobB
build job: JobB,
      wait: true

...but I wish I can do this (for illustration only, the cron option does not exist of course)

Step in JobA to trigger JobB to run around 9:00pm ET
build job: JobB,
      cron: "H 21 * * 1",
      wait: true

Any ideas? Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c2a2611f-b740-4a05-8576-30a35f9ec006n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

ZillaYT
In reply to this post by Fabi
Hi Fabi,

Great idea. How can JobA set a flag for JobB that persists when JobB runs at 9:00pm ET?

On Tuesday, September 15, 2020 at 10:56:48 AM UTC-4 fcenedese wrote:

>...but I wish I can do this (for illustration only, the cron option does not exist of course)
>
>Step in JobA to trigger JobB to run around 9:00pm ET
>build job: JobB,
> cron: "H 21 * * 1",
> wait: true

How about JobB always runs at 9 (started from cron)
and always checks first, whether it should be executed
or not. JobA would set a "flag" or variable or whatever
to let JobB know that it should go on, once it's been
started.

bye Fabi

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c92dae95-8545-4334-ae72-31c40ab48acbn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

Fabi
At 17:07 15.09.2020, [hidden email] wrote:

>Hi Fabi,
>
>Great idea. How can JobA set a flag for JobB that persists when JobB runs at 9:00pm ET?

That depends on your system. I don't know if there's a Jenkins internal
way to do this. But if the jobs run on the same machine then maybe
you could set an environment variable, or create a file at a specific
location. Maybe leave a file on a network share. Use anything that
will persist and is accessible from both jobs.

bye  Fabi

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20200915152556.4BDF9421354D%40macserver.private.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

ZillaYT
In reply to this post by ZillaYT
Fabi,

Using this trick? https://www.quora.com/How-can-I-pass-a-parameter-from-one-job-to-another-in-Jenkins-using-property-file

On Tuesday, September 15, 2020 at 11:07:18 AM UTC-4 [hidden email] wrote:
Hi Fabi,

Great idea. How can JobA set a flag for JobB that persists when JobB runs at 9:00pm ET?

On Tuesday, September 15, 2020 at 10:56:48 AM UTC-4 fcenedese wrote:

>...but I wish I can do this (for illustration only, the cron option does not exist of course)
>
>Step in JobA to trigger JobB to run around 9:00pm ET
>build job: JobB,
> cron: "H 21 * * 1",
> wait: true

How about JobB always runs at 9 (started from cron)
and always checks first, whether it should be executed
or not. JobA would set a "flag" or variable or whatever
to let JobB know that it should go on, once it's been
started.

bye Fabi

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/61c54bf6-3da4-40cc-abad-cb766ed7d997n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

Gianluca
In reply to this post by ZillaYT
Yes, it explains.

I would suggest to use intermediate artifacts / published files to use on the "Deploy" job to know what to do instead of trigger that from "Build" job.
(I'm calling "Build" the one that runs on mid-day and "Deploy" the one that runs at "H 21 * * 1")

So, in my suggestion the flow would be that "Deploy" job will be triggered by Jenkins base on "cron" trigger and when it runs, it will checks if there is a list of thing to deploy produced by "Build" job.
You can do the latter in many ways. One that's part of the Jenkins core is archiveArtifacts: https://www.jenkins.io/doc/pipeline/steps/core/
So, "Build" job will archive, let's say a JSON listing all microservices that need to be deployed. Then "Deploy" job will look for that list and if it's not empty, it will deploy all those listed microservices.

I hope that helps.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 16:05:46 UTC+1 [hidden email] ha scritto:
Thanks for responding Gianluca.

So I have a Jenkins job that builds production code mid-day, but does NOT deploy it. We have a a separate deployment job that's cron'ed at "H 21 * * 1" to deploy the code built by the mid-day build job

Part of the mid-day build is to check if certain microservices' versions need to be deployed to production as well, and I'd like for it to trigger a job for each microservice it needs to deploy at "H/30 20 * * 1". IOW the needed microservices can not be deployed mid-day either.

Hope that explains it.
On Tuesday, September 15, 2020 at 10:47:34 AM UTC-4 Gianluca wrote:
From what I know that's specific thing is not possible.
And to be honest, it's quite strange as well.

Maybe if you explain us why are you trying to do that, we could suggest alternatives that are possible in Jenkins.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 [hidden email] ha scritto:
I see this, but I don't understand how to implement it for my use case.

I want JobA to trigger JobB, but at a certain time. I do this now

Step in JobA to trigger JobB
build job: JobB,
      wait: true

...but I wish I can do this (for illustration only, the cron option does not exist of course)

Step in JobA to trigger JobB to run around 9:00pm ET
build job: JobB,
      cron: "H 21 * * 1",
      wait: true

Any ideas? Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/32d9e958-5e42-431d-88eb-fd944435a0ccn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to trigger a job at a certain time in Jenkins pipeline?

ZillaYT
Gianluca,

Perfect. I'll look into this.

Thanks,
Chris

On Tuesday, September 15, 2020 at 11:26:48 AM UTC-4 Gianluca wrote:
Yes, it explains.

I would suggest to use intermediate artifacts / published files to use on the "Deploy" job to know what to do instead of trigger that from "Build" job.
(I'm calling "Build" the one that runs on mid-day and "Deploy" the one that runs at "H 21 * * 1")

So, in my suggestion the flow would be that "Deploy" job will be triggered by Jenkins base on "cron" trigger and when it runs, it will checks if there is a list of thing to deploy produced by "Build" job.
You can do the latter in many ways. One that's part of the Jenkins core is archiveArtifacts: https://www.jenkins.io/doc/pipeline/steps/core/
So, "Build" job will archive, let's say a JSON listing all microservices that need to be deployed. Then "Deploy" job will look for that list and if it's not empty, it will deploy all those listed microservices.

I hope that helps.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 16:05:46 UTC+1 [hidden email] ha scritto:
Thanks for responding Gianluca.

So I have a Jenkins job that builds production code mid-day, but does NOT deploy it. We have a a separate deployment job that's cron'ed at "H 21 * * 1" to deploy the code built by the mid-day build job

Part of the mid-day build is to check if certain microservices' versions need to be deployed to production as well, and I'd like for it to trigger a job for each microservice it needs to deploy at "H/30 20 * * 1". IOW the needed microservices can not be deployed mid-day either.

Hope that explains it.
On Tuesday, September 15, 2020 at 10:47:34 AM UTC-4 Gianluca wrote:
From what I know that's specific thing is not possible.
And to be honest, it's quite strange as well.

Maybe if you explain us why are you trying to do that, we could suggest alternatives that are possible in Jenkins.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 [hidden email] ha scritto:
I see this, but I don't understand how to implement it for my use case.

I want JobA to trigger JobB, but at a certain time. I do this now

Step in JobA to trigger JobB
build job: JobB,
      wait: true

...but I wish I can do this (for illustration only, the cron option does not exist of course)

Step in JobA to trigger JobB to run around 9:00pm ET
build job: JobB,
      cron: "H 21 * * 1",
      wait: true

Any ideas? Thanks!

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d0720834-d0ea-4dcc-a808-75448feb7e2an%40googlegroups.com.