@Override public String toString() { if (project == null) { return "<broken data JENKINS-45892>"; } return project.getFullName() + " #" + number; }
/** * Returns true if {@link BuildPtr} points to the given job. */ public boolean is(Job job) { return job.getFullName().equals(name); }
/** * Returns true if this cause points to a build in the specified job. */ public boolean pointsTo(Job<?,?> j) { return j.getFullName().equals(upstreamProject); }
/** * Gets the names of all the {@link Job}s. */ public Collection<String> getJobNames() { List<String> names = new ArrayList<String>(); for (Job j : allItems(Job.class)) names.add(j.getFullName()); Collections.sort(names, String.CASE_INSENSITIVE_ORDER); return names; }
/** * Ordering based on build numbers. * If numbers are equal order based on names of parent projects. */ public int compareTo(@Nonnull RunT that) { final int res = this.number - that.number; if (res == 0) return this.getParent().getFullName().compareTo(that.getParent().getFullName()); return res; }
/** * Produces an identifier for this run unique in the system. * @return the {@link Job#getFullName}, then {@code #}, then {@link #getNumber} * @see #fromExternalizableId */ public @Nonnull String getExternalizableId() { return project.getFullName() + "#" + getNumber(); }
public RangeSet getRangeSet(Job job) { return getRangeSet(job.getFullName()); }
/** * Returns true if {@link BuildPtr} points to the given run. */ public boolean is(Run r) { return r.getNumber()==number && r.getParent().getFullName().equals(name); }
public AutoCompletionCandidates doAutoCompleteUpstreamProjects(@QueryParameter String value) { AutoCompletionCandidates candidates = new AutoCompletionCandidates(); List<Job> jobs = Jenkins.getInstance().getItems(Job.class); for (Job job: jobs) { if (job.getFullName().startsWith(value)) { if (job.hasPermission(Item.READ)) { candidates.add(job.getFullName()); } } } return candidates; }
@Override public String toString(Object object) { Run<?,?> run = (Run<?,?>) object; return run.getParent().getFullName() + "#" + run.getNumber(); } });
public BuildPtr(Run run) { this( run.getParent().getFullName(), run.getNumber() ); }
/** * Adds a usage reference to the build. * @param b {@link Run} to be referenced in {@link #usages} * @since 1.577 */ public synchronized void addFor(@Nonnull Run b) throws IOException { add(b.getParent().getFullName(), b.getNumber()); }
public String getEntryID(Run entry) { return "tag:" + "hudson.dev.java.net," + entry.getTimestamp().get(Calendar.YEAR) + ":" + entry.getParent().getFullName()+':'+entry.getId(); }
/** * Creates a new build of this project for immediate execution. * Calls the ({@link Job}) constructor of {@link #getBuildClass}. * Suitable for {@link SubTask#createExecutable}. */ public final synchronized RunT newBuild() throws IOException { try { RunT lastBuild = getBuildClass().getConstructor(asJob().getClass()).newInstance(asJob()); builds.put(lastBuild); lastBuild.getPreviousBuild(); // JENKINS-20662: create connection to previous build return lastBuild; } catch (InvocationTargetException e) { LOGGER.log(Level.WARNING, String.format("A new build could not be created in job %s", asJob().getFullName()), e); throw handleInvocationTargetException(e); } catch (ReflectiveOperationException | IllegalStateException e) { LOGGER.log(Level.WARNING, String.format("A new build could not be created in job %s", asJob().getFullName()), e); throw new Error(e); } }
public UpstreamCause(Run<?, ?> up) { upstreamBuild = up.getNumber(); upstreamProject = up.getParent().getFullName(); upstreamUrl = up.getParent().getUrl(); upstreamCauses = new ArrayList<Cause>(); Set<String> traversed = new HashSet<String>(); for (Cause c : up.getCauses()) { upstreamCauses.add(trim(c, MAX_DEPTH, traversed)); } }
/** * Builds up the environment variable map that's sufficient to identify a process * as ours. This is used to kill run-away processes via {@link ProcessTree#killAll(Map)}. */ public @Nonnull final EnvVars getCharacteristicEnvVars() { EnvVars env = getParent().getCharacteristicEnvVars(); env.put("BUILD_NUMBER",String.valueOf(number)); env.put("BUILD_ID",getId()); env.put("BUILD_TAG","jenkins-"+getParent().getFullName().replace('/', '-')+"-"+number); return env; }
private List<? extends ParameterValue> filter(List<ParameterValue> parameters) { if (this.run == null) { return parameters; } if (this.parameterDefinitionNames == null) { return parameters; } Boolean shouldKeepFlag = SystemProperties.optBoolean(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME); if (shouldKeepFlag != null && shouldKeepFlag.booleanValue()) { return parameters; } List<ParameterValue> filteredParameters = new ArrayList<ParameterValue>(); for (ParameterValue v : this.parameters) { if (this.parameterDefinitionNames.contains(v.getName()) || isSafeParameter(v.getName())) { filteredParameters.add(v); } else if (shouldKeepFlag == null) { LOGGER.log(Level.WARNING, "Skipped parameter `{0}` as it is undefined on `{1}`. Set `-D{2}=true` to allow " + "undefined parameters to be injected as environment variables or `-D{3}=[comma-separated list]` to whitelist specific parameter names, " + "even though it represents a security breach or `-D{2}=false` to no longer show this message.", new Object [] { v.getName(), run.getParent().getFullName(), KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME, SAFE_PARAMETERS_SYSTEM_PROPERTY_NAME }); } } return filteredParameters; }
private static SaveableReference referTo(Saveable s) { if (s instanceof Run) { Job parent = ((Run) s).getParent(); if (Jenkins.getInstance().getItemByFullName(parent.getFullName()) == parent) { return new RunSaveableReference((Run) s); } } return new SimpleSaveableReference(s); }
/** * Standard implementation of {@link ParameterizedJob#doBuildWithParameters}. */ @SuppressWarnings("deprecation") public final void doBuildWithParameters(StaplerRequest req, StaplerResponse rsp, @QueryParameter TimeDuration delay) throws IOException, ServletException { hudson.model.BuildAuthorizationToken.checkPermission(asJob(), asJob().getAuthToken(), req, rsp); ParametersDefinitionProperty pp = asJob().getProperty(ParametersDefinitionProperty.class); if (!asJob().isBuildable()) { throw HttpResponses.error(SC_CONFLICT, new IOException(asJob().getFullName() + " is not buildable!")); } if (pp != null) { pp.buildWithParameters(req, rsp, delay); } else { throw new IllegalStateException("This build is not parameterized!"); } }
/** * Builds up the environment variable map that's sufficient to identify a process * as ours. This is used to kill run-away processes via {@link ProcessTree#killAll(Map)}. */ public EnvVars getCharacteristicEnvVars() { EnvVars env = new EnvVars(); env.put("JENKINS_SERVER_COOKIE",SERVER_COOKIE.get()); env.put("HUDSON_SERVER_COOKIE",SERVER_COOKIE.get()); // Legacy compatibility env.put("JOB_NAME",getFullName()); env.put("JOB_BASE_NAME", getName()); return env; }