How to use time based triggers for different stages in Jenkins file

Viewed 197

First stage need to trigger at every day 6AM and second stage need to be trigged at every Sunday and Wednesday 5AM, how can i achive this?

pipeline { agent { node {label 'awscli'} }

    stages {
        stage('run command1') {
            steps {
               withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'SSM1', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY']]) {
                sh """
                aws ssm send-command --list documents
                }
            }
        stage('run command2') {
            steps {
               withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'SSM1', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY']]) {
                sh """
                aws ssm send-command --list documents
                }
        }
    }
}
0 Answers
Related