问题
I have created the parameter but i am unable to pass that variable while creating the cron
job.
job("dev_testing")
{
parameters
{
booleanParam('security_scan', true)
choiceParam('OPTION', ['false (default)', 'true',])
}
triggers
{
cron('H 23 * * 6 %security_scan; true')
}
}
Following is the error: ERROR: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (javaposse.jobdsl.dsl.helpers.triggers.TriggerContext parameterizedTimerTrigger script$_run_closure1$_closure2$_closure3)
回答1:
I dont know which plugins you have installed, but the Parameterized Scheduler plugin should help you with your use case.
Per their documentation, the below should work:
triggers {
parameterizedCron('''H 23 * * 6 %security_scan=true''')
}
This also worked for me:
triggers {
parameterizedTimerTrigger {
parameterizedSpecification('H 23 * * 6 %security_scan=true')
}
}
回答2:
I know this is an old thread - but I just ran into this lately and couldn't get multiple triggers to work for the life of me. Finally I got it working so:
triggers {
parameterizedTimerTrigger {
parameterizedSpecification('''H 21 * * 0-4 %APPLICATION=php
H 23 * * 0-4 %APPLICATION=java''')
}
}
来源:https://stackoverflow.com/questions/52666920/dsl-for-triggering-cron-with-a-parameter-i-have-defined-the-parameter-in-the-jo