0
votes

I'm implementing a way to trigger jenkins jobs and to schedule them with php in my site. The way I'm doing the "on-the-fly" trigger is by simply calling the url of the job with some parameters (I'm also using Build Token Root Plugin so I can trigger the jobs without authentication).

Example below:

$data = array(
  'job' => 'JOB NAME',
  'token' => 'job_token',
  'parameter1' => 'some parameter',
);

$options = array(
  'method' => 'POST',
  'data' => drupal_http_build_query($data),
  'timeout' => 15,
  'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);

drupal_http_request('http://localhost:8080/buildByToken/buildWithParameters', $options);

I can trigger the job with multiple parameters but I need to schedule the build. In jenkins there is this option "Build periodically" but it's not a parameter.

Anyone knows a way to schedule the job trough the url way?

Thanks!

1

1 Answers

0
votes

You can add ?delay=300secs to the end of the URL to schedule the job to start in five minutes.

Note that sec and secs are currently the only accepted duration units.