Search in sources :

Example 1 with ChangeLogSet

use of hudson.scm.ChangeLogSet in project blueocean-plugin by jenkinsci.

the class PipelineRunImpl method getChangeSet.

@Override
public Container<BlueChangeSetEntry> getChangeSet() {
    Map<String, BlueChangeSetEntry> m = new LinkedHashMap<>();
    int cnt = 0;
    for (ChangeLogSet<? extends Entry> cs : run.getChangeSets()) {
        for (ChangeLogSet.Entry e : cs) {
            cnt++;
            String id = e.getCommitId();
            if (id == null)
                id = String.valueOf(cnt);
            m.put(id, new ChangeSetResource(e, this));
        }
    }
    return Containers.fromResourceMap(getLink(), m);
}
Also used : ChangeLogSet(hudson.scm.ChangeLogSet) Entry(hudson.scm.ChangeLogSet.Entry) BlueChangeSetEntry(io.jenkins.blueocean.rest.model.BlueChangeSetEntry) ChangeSetResource(io.jenkins.blueocean.service.embedded.rest.ChangeSetResource) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ChangeLogSet

use of hudson.scm.ChangeLogSet in project jenkins-hipchat-plugin by jlewallen.

the class ActiveNotifier method getChanges.

String getChanges(AbstractBuild r) {
    if (!r.hasChangeSetComputed()) {
        logger.info("No change set computed...");
        return null;
    }
    ChangeLogSet changeSet = r.getChangeSet();
    List<Entry> entries = new LinkedList<Entry>();
    Set<AffectedFile> files = new HashSet<AffectedFile>();
    for (Object o : changeSet.getItems()) {
        Entry entry = (Entry) o;
        logger.info("Entry " + o);
        entries.add(entry);
        files.addAll(entry.getAffectedFiles());
    }
    if (entries.isEmpty()) {
        logger.info("Empty change...");
        return null;
    }
    Set<String> authors = new HashSet<String>();
    for (Entry entry : entries) {
        authors.add(entry.getAuthor().getDisplayName());
    }
    MessageBuilder message = new MessageBuilder(notifier, r);
    message.append("Started by changes from ");
    message.append(StringUtils.join(authors, ", "));
    message.append(" (");
    message.append(files.size());
    message.append(" file(s) changed)");
    return message.appendOpenLink().toString();
}
Also used : AffectedFile(hudson.scm.ChangeLogSet.AffectedFile) Entry(hudson.scm.ChangeLogSet.Entry) ChangeLogSet(hudson.scm.ChangeLogSet) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

ChangeLogSet (hudson.scm.ChangeLogSet)2 Entry (hudson.scm.ChangeLogSet.Entry)2 AffectedFile (hudson.scm.ChangeLogSet.AffectedFile)1 BlueChangeSetEntry (io.jenkins.blueocean.rest.model.BlueChangeSetEntry)1 ChangeSetResource (io.jenkins.blueocean.service.embedded.rest.ChangeSetResource)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1