How queue a single action across multiple Jenkins jobs and not queue the entire job?

48 views
Skip to first unread message

andrew...@xtra.co.nz

unread,
May 12, 2015, 9:03:12 PM5/12/15
to jenkin...@googlegroups.com
My plugin interfaces with an external tool (Inedo BuildMaster) and in one special circumstance I need to ensure that any calls to BuildMaster from seperate jobs are queued and the second call only happens once the first is complete.

I don't to queue the entire job as the Lockable Resources and Locks and Latches Plugin's plugins do.  I just want to pause the job when another job is running the same task - and is requesting the same information.

Does anyone have any suggestions on where to start or know of a plugin that does something similar?

Thanks
  Andrew

andrew...@xtra.co.nz

unread,
May 14, 2015, 8:35:14 PM5/14/15
to jenkin...@googlegroups.com
Am I being overly ambitious and just need to resign myself to the fact that I need to block the entire Jenkins job when a resource is locked by another job, and not just block the individual build step?

I've discovered that ResourceActivity is close to what I require, the problem is that once the build is underway I cannot update the resouce that I am trying to lock.

Ideally in the perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) method I would:
  1. Set the resource that I want to lock to reserve its place in the queue
  2. Notify Jenkins that it needs to update the resource locks for this build - ie Jenkins would call getResourceList() again
  3. Check if any other jobs already have the resource locked and sit waiting wait unit the locked resource is available again before proceeding


public class SelectApplicationBuilder extends Builder implements ResourceActivity {
     
...

     @Override
     public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException {
        ...
     }

     @Override
     public ResourceList getResourceList() {
         
System.out.println("==================BuildMaster Application Resource " + this.applicationId);
         
         
ResourceList list = new ResourceList();
         
Resource r = new Resource("BuildMaster Application " + this.applicationId );
         list
.w(r);
         
         
return list;
     
}

     
// ResourceActivity
     
@Override
     
public String getDisplayName() {
         
return "BuildMaster Application Resource";
     
}
}


Reply all
Reply to author
Forward
0 new messages