Search in sources :

Example 1 with FingerprintAction

use of hudson.tasks.Fingerprinter.FingerprintAction in project hudson-2.x by hudson.

the class AbstractBuild method getDownstreamRelationship.

/**
     * 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, 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;
}
Also used : BuildPtr(hudson.model.Fingerprint.BuildPtr) RangeSet(hudson.model.Fingerprint.RangeSet) FingerprintAction(hudson.tasks.Fingerprinter.FingerprintAction)

Example 2 with FingerprintAction

use of hudson.tasks.Fingerprinter.FingerprintAction in project hudson-2.x by hudson.

the class AbstractBuild method getUpstreamRelationship.

/**
     * 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.
     */
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;
}
Also used : RangeSet(hudson.model.Fingerprint.RangeSet) BuildPtr(hudson.model.Fingerprint.BuildPtr) FingerprintAction(hudson.tasks.Fingerprinter.FingerprintAction)

Example 3 with FingerprintAction

use of hudson.tasks.Fingerprinter.FingerprintAction in project hudson-2.x by hudson.

the class AbstractBuild method getDependencyChanges.

/**
     * Gets the changes in the dependency between the given build and this build.
     */
public Map<AbstractProject, DependencyChange> getDependencyChanges(AbstractBuild from) {
    // make it easy to call this from views
    if (from == null)
        return Collections.emptyMap();
    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();
    Map<AbstractProject, Integer> odep = o.getDependencies();
    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;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) FingerprintAction(hudson.tasks.Fingerprinter.FingerprintAction)

Aggregations

FingerprintAction (hudson.tasks.Fingerprinter.FingerprintAction)3 BuildPtr (hudson.model.Fingerprint.BuildPtr)2 RangeSet (hudson.model.Fingerprint.RangeSet)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1