public List<String> getValues(Job<?, ?> job) { List<String> values = new ArrayList<String>(); PrioritySorterJobProperty prop = job.getProperty(PrioritySorterJobProperty.class); if (prop != null) { values.add(String.valueOf(prop.priority)); } else { values.add(DEFAULT_PRIORITY); } return values; }
/** Erase aliases from newly created projects by copying. */ @Override public void onCopied(Item src, Item item) { if (!(item instanceof Job)) return; Job<?, ?> job = (Job<?, ?>) item; PermalinkStorage storage = job.getProperty(PermalinkStorage.class); if (storage == null) return; try { job.removeProperty(storage); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Unable to erase aliases when coppying " + item.getFullName(), ex); } }
@SuppressWarnings("unchecked") protected boolean matchesDefaultValue(Job job) { ParametersDefinitionProperty property = (ParametersDefinitionProperty) job.getProperty(ParametersDefinitionProperty.class); if (property != null) { List<ParameterDefinition> defs = property.getParameterDefinitions(); for (ParameterDefinition def : defs) { boolean multiline = isValueMultiline(def); String svalue = getStringValue(def); boolean matches = matchesParameter(def.getName(), svalue, multiline, def.getDescription()); if (matches) { return true; } } } return false; }
public void fireEvent(Run<?, ?> run, ReactorEvent event) { for (Job j : Jenkins.getInstance().getAllItems(Job.class)) { ReactorJobProperty rjp = (ReactorJobProperty) j.getProperty(ReactorJobProperty.class); if (rjp != null && !run.getParent().equals(j)) { StringScriptSource scriptSource = new StringScriptSource(rjp.reactorScript); ReactorGroovy rg = new ReactorGroovy(scriptSource); try { if (rg.perform(event)) { ((BuildableItem) j).scheduleBuild(new ReactorCause(event)); } } catch (Exception ex) { ex.printStackTrace(); } } } }
@SuppressWarnings("unchecked") public EnvInjectJobProperty getEnvInjectJobProperty(AbstractBuild build) { if (build == null) { throw new IllegalArgumentException("A build object must be set."); } Job job; if (build instanceof MatrixRun) { job = ((MatrixRun) build).getParentBuild().getParent(); } else { job = build.getParent(); } EnvInjectJobProperty envInjectJobProperty = (EnvInjectJobProperty) job.getProperty(EnvInjectJobProperty.class); if (envInjectJobProperty != null) { EnvInjectJobPropertyInfo info = envInjectJobProperty.getInfo(); if (info != null && envInjectJobProperty.isOn()) { return envInjectJobProperty; } } return null; }
@SuppressWarnings("unchecked") public boolean setValues(Job<?, ?> job, List<String> set) { String value = set.iterator().next(); int priority; try { priority = Integer.parseInt(value); } catch (NumberFormatException nfe) { priority = DEFAULT_PRIORITY_INT; } boolean changed; PrioritySorterJobProperty prop = job.getProperty(PrioritySorterJobProperty.class); if (prop == null) { changed = (priority != DEFAULT_PRIORITY_INT); if (changed) { try { prop = new PrioritySorterJobProperty(priority); job.addProperty((JobProperty) prop); } catch (IOException e) { return false; } } } else { int oldPriority = prop.priority; changed = (oldPriority != priority); if (changed) { try { job.removeProperty((JobProperty) prop); prop = new PrioritySorterJobProperty(priority); job.addProperty((JobProperty) prop); } catch (IOException e) { return false; } } } return changed; }
/** @return the ACL specific to the CSFE project, if available. Otherwise, return the root ACL. */ @Override public ACL getACL(Job<?, ?> job) { CNAuthProjectProperty capp = job.getProperty(CNAuthProjectProperty.class); if (capp != null) { String projectId = capp.getProjectId(); if (projectId != null && !projectId.equals("")) { return new CNRootACL( this.adminUsers, this.adminGroups, this.readUsers, this.readGroups, new CNProjectACL(projectId)); } } // for jobs that are not associated with any project, we'll make it configuratble by any // authenticated user return new CNRootACL( this.adminUsers, this.adminGroups, this.readUsers, this.readGroups, new CNAuthenticatedUserACL()); }