Pipeline Workflow && Blocking other jobs

93 views
Skip to first unread message

Pierre Lerouge

unread,
Mar 7, 2016, 10:53:56 AM3/7/16
to Jenkins Users
Hi, 

I'm trying to block some job when a pipeline is running.
More precisely I'm trying to find a wrapper around certain stages which could prevent other job to run while this stage is running.

My main problem is the following:
   My workflow plugin launch a maven:release at some point, which create events in the SCM, wich run a standard build job that destroy my integration platform.

I don't know if it's clear.
I usually use the Exclusion plugin : https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin 
To prevent a job running when there is already another one using this resource.
I've seen that there are some commits that allow this plugin to be run within a pipeline : 
But I really don't know how to implement this.

Have anybody already set up this kind of thing ? 
Thank you for your help.

Pierre Lerouge

unread,
Mar 10, 2016, 3:09:23 AM3/10/16
to Jenkins Users
Hey, 
Nobody had this need with the pipeline plugin ?

Baptiste Mathus

unread,
Mar 11, 2016, 3:22:37 AM3/11/16
to jenkins...@googlegroups.com

Gonna probably require twiddling with the API, but it should be possible to use one of the lock plugins (throttle one e.g.).

* On the non pipeline one: use it normally
* On the pipeline one: wrap the required groovy code in a @NonCPS function to attack the plugin API and acquire the lock.

My 2 cents

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/be92093a-baa1-4f2a-86e2-8904b7834516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pierre Lerouge

unread,
Mar 15, 2016, 6:05:20 AM3/15/16
to Jenkins Users, m...@batmat.net
Hi Baptiste, 

Thank you for your awnser, 
I've tried something like that, but no luck : 
 node(){
     stage "test"
     allocate('test')
     sleep time: 15, unit: 'MINUTES'
     sh "echo 'yes'" }

@NonCPS
def allocate(String resource){

  throttle = new hudson.plugins.throttleconcurrents.ThrottleJobProperty(
    maxConcurrentPerNode=1,
    maxConcurrentTotal=1,
    categories = [resource],
    throttleEnabled=true,
    throttleOption="category",
    matrixOptions=null
    )
  throttle.setOwner()
  throttle = null
  return true
}

It has no effect on the Throttle plugin, 
(I had to set 'throttle' to null otherwise I would get no Serializable errors even if its a NonCPS method ...)

If you have any Ideas ? 

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages