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 [email protected] 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4362ba69-cfb1-4512-8cea-203854825a93n%40googlegroups.com.

Reply via email to