It's all about the answers!

Ask a question

Is it possible to reset a server job count using the api?


Ron Roberts (111) | asked Jun 29 '15, 5:17 p.m.
edited Jun 29 '15, 10:33 p.m.
We have servers with MaxJobCount =1;  Often, the job count will be set to "1" even when no job step is running on that server object.  I am able to query all active jobs and determine that no active job step is using that server.  I can use the api to query the job count, but I do not see a function to set or reset the job count.

perl or java would be ok, but I would prefer perl.

my $running = BuildForge::Services::DBO::Build->findRunning($connection);  # all active jobs
foreach my $build (@$running)  {   # examine each job
   my $rslts = $build->getResults();  # get all steps
      foreach my $rslt (@$rslts) { # examine each step
         my $result = $rslt->getResult();  # if "RUNNING" this step is active
         my $server_uuid = $rslt->getServerUuid(); # determine what server it is running on
         .....

my $servers = BuildForge::Services::DBO::Server->findAll($connection);  # get all servers
    foreach my $server (@$servers) {
        my $jobs = $server->getCurrentJobs();  # get the job count
        if ($jobs>0) {
            # server thinks it has an active job   
        }
      
If the server job count is > 0 and no active job/step is using it I need something like:

   $server->setCurrentJobs(0);  or $server->resetCurrentJobs();  or equivalent.


Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.