use of hudson.scm.ChangeLogSet.Entry in project hudson-2.x by hudson.
the class ListChangesCommand method act.
@Override
protected int act(List<AbstractBuild<?, ?>> builds) throws IOException {
// No other permission check needed.
switch(format) {
case XML:
PrintWriter w = new PrintWriter(stdout);
w.println("<changes>");
for (AbstractBuild build : builds) {
w.println("<build number='" + build.getNumber() + "'>");
ChangeLogSet<?> cs = build.getChangeSet();
Model p = new ModelBuilder().get(cs.getClass());
p.writeTo(cs, Flavor.XML.createDataWriter(cs, w));
w.println("</build>");
}
w.println("</changes>");
w.flush();
break;
case CSV:
for (AbstractBuild build : builds) {
ChangeLogSet<?> cs = build.getChangeSet();
for (Entry e : cs) {
stdout.printf("%s,%s\n", QuotedStringTokenizer.quote(e.getAuthor().getId()), QuotedStringTokenizer.quote(e.getMsg()));
}
}
break;
case PLAIN:
for (AbstractBuild build : builds) {
ChangeLogSet<?> cs = build.getChangeSet();
for (Entry e : cs) {
stdout.printf("%s\t%s\n", e.getAuthor(), e.getMsg());
for (String p : e.getAffectedPaths()) stdout.println(" " + p);
}
}
break;
}
return 0;
}
use of hudson.scm.ChangeLogSet.Entry in project hudson-2.x by hudson.
the class AbstractBuild method getCulprits.
/**
* List of users who committed a change since the last non-broken build till now.
*
* <p>
* This list at least always include people who made changes in this build, but
* if the previous build was a failure it also includes the culprit list from there.
* Culprits of unstable build are also included
* see <a href="http://issues.hudson-ci.org/browse/HUDSON-4617">HUDSON-4617</a> for details
* @return
* can be empty but never null.
*/
@Exported
public Set<User> getCulprits() {
if (culprits == null) {
Set<User> r = new HashSet<User>();
R p = getPreviousCompletedBuild();
if (p != null && isBuilding()) {
Result pr = p.getResult();
if (pr != null && pr.isWorseOrEqualTo(Result.UNSTABLE)) {
// we are still building, so this is just the current latest information,
// but we seems to be failing so far, so inherit culprits from the previous build.
// isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
// this information
r.addAll(p.getCulprits());
}
}
for (Entry e : getChangeSet()) r.add(e.getAuthor());
if (upstreamCulprits) {
// If we have dependencies since the last successful build, add their authors to our list
R previousBuild = getPreviousSuccessfulBuild();
if (previousBuild != null) {
Map<AbstractProject, AbstractBuild.DependencyChange> depmap = getDependencyChanges(previousBuild);
for (AbstractBuild.DependencyChange dep : depmap.values()) {
for (AbstractBuild<?, ?> b : dep.getBuilds()) {
for (Entry entry : b.getChangeSet()) {
r.add(entry.getAuthor());
}
}
}
}
}
return r;
}
return new AbstractSet<User>() {
public Iterator<User> iterator() {
return new AdaptedIterator<String, User>(culprits.iterator()) {
protected User adapt(String id) {
return User.get(id);
}
};
}
public int size() {
return culprits.size();
}
};
}
use of hudson.scm.ChangeLogSet.Entry in project hudson-2.x by hudson.
the class AbstractProject method doRssChangelog.
/**
* RSS feed for changes in this project.
*/
public void doRssChangelog(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
class FeedItem {
ChangeLogSet.Entry e;
int idx;
public FeedItem(Entry e, int idx) {
this.e = e;
this.idx = idx;
}
AbstractBuild<?, ?> getBuild() {
return e.getParent().build;
}
}
List<FeedItem> entries = new ArrayList<FeedItem>();
for (R r = getLastBuild(); r != null; r = r.getPreviousBuild()) {
int idx = 0;
for (ChangeLogSet.Entry e : r.getChangeSet()) entries.add(new FeedItem(e, idx++));
}
RSS.forwardToRss(getDisplayName() + ' ' + getScm().getDescriptor().getDisplayName() + " changes", getUrl() + "changes", entries, new FeedAdapter<FeedItem>() {
public String getEntryTitle(FeedItem item) {
return "#" + item.getBuild().number + ' ' + item.e.getMsg() + " (" + item.e.getAuthor() + ")";
}
public String getEntryUrl(FeedItem item) {
return item.getBuild().getUrl() + "changes#detail" + item.idx;
}
public String getEntryID(FeedItem item) {
return getEntryUrl(item);
}
public String getEntryDescription(FeedItem item) {
StringBuilder buf = new StringBuilder();
for (String path : item.e.getAffectedPaths()) buf.append(path).append('\n');
return buf.toString();
}
public Calendar getEntryTimestamp(FeedItem item) {
return item.getBuild().getTimestamp();
}
public String getEntryAuthor(FeedItem entry) {
return Mailer.descriptor().getAdminAddress();
}
}, req, rsp);
}
use of hudson.scm.ChangeLogSet.Entry in project blueocean-plugin by jenkinsci.
the class PipelineRunImpl method getChangeSet.
@Override
@Nonnull
public Container<BlueChangeSetEntry> getChangeSet() {
// If this run is a replay then return the changesets from the original run
ReplayCause replayCause = run.getCause(ReplayCause.class);
if (replayCause != null) {
Run run = this.run.getParent().getBuildByNumber(replayCause.getOriginalNumber());
if (run == null) {
return Containers.empty(getLink());
}
BlueRun blueRun = BlueRunFactory.getRun(run, parent);
if (blueRun == null) {
return Containers.empty(getLink());
}
return blueRun.getChangeSet();
} else {
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(organization, e, this));
}
}
return Containers.fromResourceMap(getLink(), m);
}
}
use of hudson.scm.ChangeLogSet.Entry 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();
}
Aggregations