Source:
public PromotionBadge isMet(final PromotionProcess promotionProcess, final AbstractBuild<?, ?> build) { final ClassLoader classLoader = Jenkins.getInstance().getPluginManager().uberClassLoader; final Binding binding = new Binding(); binding.setVariable("promotionProcess", promotionProcess); binding.setVariable("build", build); Object result = null; try { result = script.evaluate(classLoader, binding); } catch (final RejectedAccessException e) { LOGGER.log(Level.WARNING, "Sandbox exception", e); } catch (final UnapprovedUsageException e) { LOGGER.log(Level.WARNING, "Unapproved script", e); } catch (final UnapprovedClasspathException e) { LOGGER.log(Level.WARNING, "Unapproved classpath", e); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Evaluation error", e); } final String displayLabel = metQualificationLabel == null ? Messages.GroovyCondition_MetQualificationLabel() : metQualificationLabel; if (Boolean.TRUE.equals(result)) { return new Badge(displayLabel, Collections.<String,String>emptyMap()); } else if (result instanceof Map && !((Map) result).isEmpty()) { final Map<String, String> variables = new HashMap<String, String>(((Map) result).size()); for (final Map.Entry entry : ((Map<Object, Object>) result).entrySet()) { final Object key = entry.getKey(); final Object value = entry.getValue(); if (key == null) { continue; } variables.put(key.toString(), value == null ? "" : value.toString()); } return new Badge(displayLabel, variables); } return null; }

Target:
public PromotionBadge isMet(final PromotionProcess promotionProcess, final AbstractBuild<?, ?> build) { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { LOGGER.log(Level.WARNING, "Missing Jenkins instance"); return null; } final PluginManager pluginManager = jenkins.getPluginManager(); if (pluginManager == null) { LOGGER.log(Level.WARNING, "Unable to retrieve PluginManager"); return null; } final ClassLoader classLoader = pluginManager.uberClassLoader; final Binding binding = new Binding(); binding.setVariable("promotionProcess", promotionProcess); binding.setVariable("build", build); binding.setVariable("jenkins", jenkins); Object result = null; try { result = script.evaluate(classLoader, binding); } catch (final RejectedAccessException e) { LOGGER.log(Level.WARNING, "Sandbox exception", e); return null; } catch (final UnapprovedUsageException e) { LOGGER.log(Level.WARNING, "Unapproved script", e); return null; } catch (final UnapprovedClasspathException e) { LOGGER.log(Level.WARNING, "Unapproved classpath", e); return null; } catch (final Exception e) { LOGGER.log(Level.WARNING, "Evaluation error", e); return null; } final String displayLabel = metQualificationLabel == null ? Messages.GroovyCondition_MetQualificationLabel() : metQualificationLabel; if (Boolean.TRUE.equals(result)) { return new Badge(displayLabel, Collections.<String,String>emptyMap()); } else if (result instanceof Map && !((Map) result).isEmpty()) { final Map<String, String> variables = new HashMap<String, String>(((Map) result).size()); for (final Map.Entry entry : ((Map<Object, Object>) result).entrySet()) { final Object key = entry.getKey(); final Object value = entry.getValue(); if (key == null) { continue; } variables.put(key.toString(), value == null ? "" : value.toString()); } return new Badge(displayLabel, variables); } return null; }