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

早过忘川 提交于 2019-12-11 17:25:03

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!