/** * @deprecated Use {@link #getAction(Class)} on {@code AbstractTestResultAction}. */ @Deprecated public Action getTestResultAction() { try { return getAction(Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.tasks.test.AbstractTestResultAction").asSubclass(Action.class)); } catch (ClassNotFoundException x) { return null; } }
/** * @deprecated Use {@link #getAction(Class)} on {@code AggregatedTestResultAction}. */ @Deprecated public Action getAggregatedTestResultAction() { try { return getAction(Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.tasks.test.AggregatedTestResultAction").asSubclass(Action.class)); } catch (ClassNotFoundException x) { return null; } }
@Deprecated public boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath workspace, BuildListener listener, @Nonnull File changelogFile) throws IOException, InterruptedException { AbstractBuild<?,?> prev = build.getPreviousBuild(); checkout((Run) build, launcher, workspace, listener, changelogFile, prev != null ? prev.getAction(SCMRevisionState.class) : null); return true; }
/** * Gets the changes in the dependency between the given build and this build. * @return empty if there is no {@link FingerprintAction} */ public Map<AbstractProject,DependencyChange> getDependencyChanges(AbstractBuild from) { if (from==null) return Collections.emptyMap(); // make it easy to call this from views FingerprintAction n = this.getAction(FingerprintAction.class); FingerprintAction o = from.getAction(FingerprintAction.class); if (n==null || o==null) return Collections.emptyMap(); Map<AbstractProject,Integer> ndep = n.getDependencies(true); Map<AbstractProject,Integer> odep = o.getDependencies(true); Map<AbstractProject,DependencyChange> r = new HashMap<AbstractProject,DependencyChange>(); for (Map.Entry<AbstractProject,Integer> entry : odep.entrySet()) { AbstractProject p = entry.getKey(); Integer oldNumber = entry.getValue(); Integer newNumber = ndep.get(p); if (newNumber!=null && oldNumber.compareTo(newNumber)<0) { r.put(p,new DependencyChange(p,oldNumber,newNumber)); } } return r; }
/** * Pushes the baseline up to the newly checked out revision. */ private void calcPollingBaseline(AbstractBuild build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { SCMRevisionState baseline = build.getAction(SCMRevisionState.class); if (baseline==null) { try { baseline = getScm().calcRevisionsFromBuild(build, launcher, listener); } catch (AbstractMethodError e) { baseline = SCMRevisionState.NONE; // pre-1.345 SCM implementations, which doesn't use the baseline in polling } if (baseline!=null) build.addAction(baseline); } pollingBaseline = baseline; }
/** * Builds up a set of variable names that contain sensitive values that * should not be exposed. The expectation is that this set is populated with * keys returned by {@link #getBuildVariables()} that should have their * values masked for display purposes. * * @since 1.378 */ public Set<String> getSensitiveBuildVariables() { Set<String> s = new HashSet<String>(); ParametersAction parameters = getAction(ParametersAction.class); if (parameters != null) { for (ParameterValue p : parameters) { if (p.isSensitive()) { s.add(p.getName()); } } } // Allow BuildWrappers to determine if any of their data is sensitive if (project instanceof BuildableItemWithBuildWrappers) { for (BuildWrapper bw : ((BuildableItemWithBuildWrappers) project).getBuildWrappersList()) { bw.makeSensitiveBuildVariables(this, s); } } return s; }
/** * Gets the dependency relationship from this build (as the sink) * and that project (as the source.) * * @return * Build number of the upstream build that feed into this build, * or -1 if no record is available (for example if there is no {@link FingerprintAction}, even if there is an {@link Cause.UpstreamCause}). */ public int getUpstreamRelationship(AbstractProject that) { FingerprintAction f = getAction(FingerprintAction.class); if (f==null) return -1; int n = -1; // look for fingerprints that point to the given project as the source, and merge them all for (Fingerprint e : f.getFingerprints().values()) { if (upstreamCulprits) { // With upstreamCulprits, we allow upstream relationships // from intermediate jobs Fingerprint.RangeSet rangeset = e.getRangeSet(that); if (!rangeset.isEmpty()) { n = Math.max(n, rangeset.listNumbersReverse().iterator().next()); } } else { BuildPtr o = e.getOriginal(); if (o!=null && o.belongsTo(that)) n = Math.max(n,o.getNumber()); } } return n; }
Map<String,String> r = new HashMap<String, String>(); ParametersAction parameters = getAction(ParametersAction.class); if (parameters!=null) {
/** * Gets the dependency relationship from this build (as the source) * and that project (as the sink.) * * @return * range of build numbers that represent which downstream builds are using this build. * The range will be empty if no build of that project matches this (or there is no {@link FingerprintAction}), but it'll never be null. */ public RangeSet getDownstreamRelationship(AbstractProject that) { RangeSet rs = new RangeSet(); FingerprintAction f = getAction(FingerprintAction.class); if (f==null) return rs; // look for fingerprints that point to this build as the source, and merge them all for (Fingerprint e : f.getFingerprints().values()) { if (upstreamCulprits) { // With upstreamCulprits, we allow downstream relationships // from intermediate jobs rs.add(e.getRangeSet(that)); } else { BuildPtr o = e.getOriginal(); if (o!=null && o.is(this)) rs.add(e.getRangeSet(that)); } } return rs; }
SCMRevisionState s = r.getAction(SCMRevisionState.class); if (s!=null) { pollingBaseline = s;
/** * Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points to, * or throws {@link hudson.fsp.WorkspaceSnapshotSCM.ResolvedFailedException} upon failing. * * @return never null. */ public Snapshot resolve() throws ResolvedFailedException { Jenkins h = Jenkins.getInstance(); AbstractProject<?,?> job = h.getItemByFullName(jobName, AbstractProject.class); if(job==null) { if(h.getItemByFullName(jobName)==null) { AbstractProject nearest = AbstractProject.findNearest(jobName); throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName,nearest.getFullName())); } else throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_IncorrectJobType(jobName)); } PermalinkList permalinks = job.getPermalinks(); Permalink p = permalinks.get(permalink); if(p==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink,jobName)); AbstractBuild<?,?> b = (AbstractBuild<?,?>)p.resolve(job); if(b==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink,jobName)); WorkspaceSnapshot snapshot = b.getAction(WorkspaceSnapshot.class); if(snapshot==null) throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName,permalink)); return new Snapshot(snapshot,b); }
private <U extends AbstractTestResultAction> U getPreviousResult(Class<U> type) { AbstractBuild<?,?> b = owner; while(true) { b = b.getPreviousBuild(); if(b==null) return null; U r = b.getAction(type); if(r!=null) return r; } }
/** * Gets the counter part of this {@link TestResult} in the specified run. * * @return null if no such counter part exists. */ public TestResult getResultInBuild(AbstractBuild<?,?> build) { AbstractTestResultAction tra = build.getAction(getParentAction().getClass()); if (tra == null) { tra = build.getAction(AbstractTestResultAction.class); } return (tra == null) ? null : tra.findCorrespondingResult(this.getId()); }
/** * @deprecated Use {@link #getAction(Class)} on {@code AbstractTestResultAction}. */ @Deprecated public Action getTestResultAction() { try { return getAction(Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.tasks.test.AbstractTestResultAction").asSubclass(Action.class)); } catch (ClassNotFoundException x) { return null; } }
/** * @deprecated Use {@link #getAction(Class)} on {@code AggregatedTestResultAction}. */ @Deprecated public Action getAggregatedTestResultAction() { try { return getAction(Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.tasks.test.AggregatedTestResultAction").asSubclass(Action.class)); } catch (ClassNotFoundException x) { return null; } }
@Deprecated public boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath workspace, BuildListener listener, @Nonnull File changelogFile) throws IOException, InterruptedException { AbstractBuild<?,?> prev = build.getPreviousBuild(); checkout((Run) build, launcher, workspace, listener, changelogFile, prev != null ? prev.getAction(SCMRevisionState.class) : null); return true; }
@Override public String evaluate(final AbstractBuild<?, ?> context, final TaskListener listener, final String macroName) throws MacroEvaluationException, IOException, InterruptedException { for (Class<? extends ResultAction<? extends BuildResult>> resultActionType : resultActions) { ResultAction<? extends BuildResult> action = context.getAction(resultActionType); if (action != null) { return evaluate(action.getResult()); } } return ""; }
@Override public Action getAction(AbstractBuild<?, ?> build, TaskListener listener) { BuildData data = build.getAction(BuildData.class); if (data == null) { listener.getLogger().println("This project doesn't use Git as SCM. Can't pass the revision to downstream"); return null; } return new RevisionParameterAction(data.getLastBuiltRevision().getSha1String()); }
/** * Attach the build action if its not already attached */ private void attachBuildAction( final AbstractBuild<?, ?> build ) { if (build.getAction(MavenBuildAction.class) == null) { build.addAction(new MavenBuildAction(build)); } }
static void setVersion(AbstractBuild build, String version) { PipelineVersionAction action = build.getAction(PipelineVersionAction.class); if (action == null) { build.addAction(new PipelineVersionAction(version)); } else { build.replaceAction(action); } build.replaceAction(getVersionParameterAction(build, version)); }