rhlin888
rhlin888

Reputation: 225

Jenkins DSL Syntax: Run Periodically With Parameters

I am trying to run a Jenkins DSL script to create jobs that build periodically with multiple parameters. So far, all I have found is parameterizedCron, but I believe that is for Jenkins Pipeline. Is there something similar for Jenkins DSL?

triggers {
    parameterizedCron('''
        H 0 * * * % Browser=Chrome;Environment=Dev;TestCase=Student_Login
        H 0 * * * % Browser=Firefox;Environment=Dev;TestCase=Student_Login
        H 0 * * * % Browser=Safari;Environment=Dev;TestCase=Student_Login
        H 0 * * * % Browser=Chrome;Environment=Test;TestCase=Student_Login
        H 0 * * * % Browser=Firefox;Environment=Test;TestCase=Student_Login
        H 0 * * * % Browser=Safari;Environment=Test;TestCase=Student_Login
        ''')
}

Upvotes: 3

Views: 1963

Answers (1)

rhlin888
rhlin888

Reputation: 225

I have found this answer.

This specifically works for the Jenkins Job DSL:

triggers {
    parameterizedTimerTrigger {
        parameterizedSpecification('''
            H 0 * * * % Browser=Chrome;Environment=Dev;TestCase=${testCaseName}
            H 0 * * * % Browser=Firefox;Environment=Dev;TestCase=${testCaseName}
            H 0 * * * % Browser=Safari;Environment=Dev;TestCase=${testCaseName}
            H 0 * * * % Browser=Chrome;Environment=Test;TestCase=${testCaseName}
            H 0 * * * % Browser=Firefox;Environment=Test;TestCase=${testCaseName}
            H 0 * * * % Browser=Safari;Environment=Test;TestCase=${testCaseName}
        ''')
    }
}

See DSL for triggering cron with a parameter. I have defined the parameter in the job above but unable to pass it in the cron using dsl scripts

Upvotes: 2

Related Questions