can I run a stage at a certain time within a pipeline

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

can I run a stage at a certain time within a pipeline

jesus fernandez
I have a declarative pipeline with 3 stages and it is using poll SCM every 10 minutes (checkout, build and deploy), but I need the last step (deploy) to be executed just once everyday (i.e. 22 o´clock)  so it keeps checking out and building everytime a change is submitted but it only deploys once a day. I have tried to use triggers cron directive within the stage but it does not work. I have thought to use the when directive but as I am new to groove I do not see how to tell jenkins "when time is 22 o´clock"

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/eeebcfd4-e1c9-4c8b-918d-05be60e26c68n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: can I run a stage at a certain time within a pipeline

Victor Martinez
triggeredBy within the stage context should help you: https://www.jenkins.io/doc/book/pipeline/syntax/#when

pipeline {
   ...
   triggers {
     cron 'H H22 * * 1-5'
   }
   stages {
        ...
        stage('deploy') {
           when { triggeredBy 'TimerTrigger' }
           ...
        }
    }
}
On Saturday, 26 September 2020 at 10:55:14 UTC+1 [hidden email] wrote:
I have a declarative pipeline with 3 stages and it is using poll SCM every 10 minutes (checkout, build and deploy), but I need the last step (deploy) to be executed just once everyday (i.e. 22 o´clock)  so it keeps checking out and building everytime a change is submitted but it only deploys once a day. I have tried to use triggers cron directive within the stage but it does not work. I have thought to use the when directive but as I am new to groove I do not see how to tell jenkins "when time is 22 o´clock"

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/4362ba69-cfb1-4512-8cea-203854825a93n%40googlegroups.com.