Example #1
0
    fclose($fo);
    fclose($fi);
    $job->set('logfile', $filename);
    $job->save();
    textResponse(200);
})->conditions(array('jobid' => '[0-9]'));
/* Jobs - Finish a job (with buildstatus and buildreason) */
$app->post('/jobs/:jobid/finish', 'isAllowed', function ($jobid) use($app) {
    if (!isset($_POST['buildstatus']) || !isset($_POST['buildreason'])) {
        textResponse(400, 'Post data missing');
    }
    $job = new Job($jobid);
    if ($job === false) {
        textResponse(204);
    }
    $machine = new Machine(Session::getMachineId());
    if (!$machine->hasJob($job->getJobId())) {
        textResponse(403, 'Job not assigned to you');
    }
    $job->unset('machine');
    $job->set('buildstatus', $_POST['buildstatus']);
    $job->set('buildreason', $_POST['buildreason']);
    $job->moveToQueue('archivequeue');
    jsonResponse(200, $job->getJobData());
})->conditions(array('jobid' => '[0-9]'));
/* Jobgroup - List details of jobgroup */
$app->get('/group/:groupid/', 'isAllowed', function ($groupid) use($app) {
    $jobgroup = new Jobgroup($groupid);
    if (!$jobgroup->exists()) {
        textResponse(404, 'Jobgroup not found');
    }