Promoted Builds plugin causes performance issues

Issue

  • Jenkins UI is unresponsive and recover after several minutes
  • Job configuration pages take a long time to load
  • You see slow requests and/or threads waiting with the following stacktraces:
[...]
    hudson.security.ACL.hasPermission(ACL.java:73)
    hudson.model.AbstractItem.hasPermission(AbstractItem.java:505)
    hudson.model.Items.getAllItems(Items.java:365)
    hudson.model.Items.getAllItems(Items.java:370)
    hudson.model.Items.getAllItems(Items.java:346)
    jenkins.model.Jenkins.getAllItems(Jenkins.java:1404)
    hudson.plugins.promoted_builds.conditions.DownstreamPassCondition$RunListenerImpl.onCompleted(DownstreamPassCondition.java:220)
    hudson.plugins.promoted_builds.conditions.DownstreamPassCondition$RunListenerImpl.onCompleted(DownstreamPassCondition.java:211)
[...]

Environment

Related Issues

JENKINS-37368

Resolution

When using the DownstreamPassCondition of the Promoted Build Plugin - i.e. the option When the following downstream projects build successfully - Jenkins looks for a match among all items. This is done via a RunListener. The current implementation of this Listener in Promoted Builds Plugin is terribly inefficient, especially in combination with Authorize Project. See JENKINS-37368 for more information.

Unfortunately there is no way to disable the condition check logic without removing a plugin or calling a System Groovy script.

Workaround 1: Disable Promotion Build plugin

If you do not use the Promotion Builds plugin, the solution is to disable the plugin.

Workaround 2: Unregister the RunListener

If you use the Promotion Builds plugin but not the DownstreamPassCondition functionality, the workaround is to unregister its Listener. For this you can run the following groovy script under Manage Jenkins > Script Console:

import hudson.plugins.promoted_builds.conditions.DownstreamPassCondition
import jenkins.model.Jenkins

Jenkins.instance.getExtensionList(DownstreamPassCondition.RunListenerImpl.class).each {
    it.unregister();
}

To keep this configuration upon restart, you should copy the above script in a Groovy Hook script “$JENKINS_HOME/init.groovy”. Please have a look at Configuring Jenkins upon start up for more information about initialization scripts.

More Information

Find Job with Promotion Process

To find out if Promotion processes are defined in your instance you can use the Plugin Usage.

Another solution is to use a Groovy script that prints all the jobs configured with a promotion process:

import hudson.model.Job

Jenkins.instance.getAllItems(Job.class)
        .findAll { item -> item.getProperty(hudson.plugins.promoted_builds.JobPropertyImpl.class) != null }
        .each { println it.fullName }
return;

Find Job with DownstreamPassConditions

To find out which jobs use the DownstreamPassCondition, you can use the following script:

import hudson.model.Job
import hudson.plugins.promoted_builds.conditions.DownstreamPassCondition

Jenkins.instance.getAllItems(Job.class)
        //Find all job with defined Promotion process(es)
        .findAll { item -> item.getProperty(hudson.plugins.promoted_builds.JobPropertyImpl.class) != null }
        .each { 
          //Find all active processes with a DownStreamPassCondition
          promotionJob -> promotionJob.getProperty(hudson.plugins.promoted_builds.JobPropertyImpl.class).getActiveItems().findAll {
            //Find all DownStreamPassCondition
            process -> process.conditions.findAll{it -> it instanceof DownstreamPassCondition}.size() > 0
          }
          println promotionJob
        }
return;
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.