5

I am trying to add a parameterized cron job using jenkins job dsl. However, every time I try to add the job I see the following error:

No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.parameterizedTimerTrigger() is applicable
for argument types: (com.manh.cp.jenkins.script$_createJob_closure3$_closure6$_closure9) values:
[com.manh.cp.jenkins.script$_createJob_closure3$_closure6$_closure9@4f7fa1a2]

I have tried both:

triggers {
   parameterizedCron('''H 20 * * * %var=a''')
}

and

triggers {
    parameterizedTimerTrigger {
        parameterizedSpecification('H 20 * * * %var=a')
    }
}

Does this still work for anyone else

parameterized scheduler v0.8 job dsl v1.76

cbwsports
  • 51
  • 3
  • Try `'H 20 * * * % var=a'` (note space around `%`). – MaratC Mar 26 '20 at 13:46
  • I get the same error with `parameterizedTimerTrigger`. When using `parameterizedCron` I get: `No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.parameterizedCron() is applicable for argument types: (String) values: [H 20 * * * % var=a]` – cbwsports Apr 01 '20 at 18:19
  • Did you figure it out @cbwsports ? Facing the same issue. – pressbyron Oct 14 '20 at 14:13

1 Answers1

3

Probably you should install the plugin first:

https://plugins.jenkins.io/parameterized-scheduler/

Then you can use the DSL script:

pipelineJob('test') {
  // ...

  parameters {
    textParam('MYVAR',
      '1',
      'Test parameter'
    )
    choiceParam('MYCHOICE',
      ['A',
       'B',
      ],
      'Test choice param'
    )
  }

  properties {
    pipelineTriggers {
      triggers {
        parameterizedTimerTrigger {
          parameterizedSpecification('''
H 18 * * * %MYVAR=1; MYCHOICE=A;
H 18 * * * %MYVAR=2; MYCHOICE=B;
''')
        }
      }
    }

  }

Please pay attention that the syntax is different in Jenkinsfiles:

pipeline {
  // ...

  parameters {
    text name: 'MYVAR',
      description: 'Test parameter',
      defaultValue: '1'
    choice name: 'MYCHOICE',
      choices: ['A', 'B',],
      description: 'Test choice param'
  }

  triggers {
    parameterizedCron('''
H 18 * * * %MYVAR=1; MYCHOICE=A;
H 18 * * * %MYVAR=2; MYCHOICE=B;
''')
  }

}
kivagant
  • 1,849
  • 2
  • 24
  • 33