Refine search
@Override @Nonnull public List<ChangeLogSet<? extends ChangeLogSet.Entry>> getChangeSets() { ChangeLogSet<? extends Entry> cs = getChangeSet(); return cs.isEmptySet() ? Collections.emptyList() : Collections.singletonList(cs); }
/** * Returns a set of paths in the workspace that was * affected by this change. * <p> * Noted: since this is a new interface, some of the SCMs may not have * implemented this interface. The default implementation for this * interface is throw UnsupportedOperationException * <p> * It doesn't throw NoSuchMethodException because I rather to throw a * runtime exception * * @return AffectedFile never null. * @since 1.309 */ public Collection<? extends AffectedFile> getAffectedFiles() { String scm = "this SCM"; ChangeLogSet parent = getParent(); if ( null != parent ) { String kind = parent.getKind(); if ( null != kind && kind.trim().length() > 0 ) scm = kind; } throw new UnsupportedOperationException("getAffectedFiles() is not implemented by " + scm); }
private ChangeLogSet<? extends Entry> calcChangeSet() { File changelogFile = new File(getRootDir(), "changelog.xml"); if (!changelogFile.exists()) return ChangeLogSet.createEmpty(this); try { return scm.parse(this,changelogFile); } catch (IOException e) { LOGGER.log(WARNING, "Failed to parse "+changelogFile,e); } catch (SAXException e) { LOGGER.log(WARNING, "Failed to parse "+changelogFile,e); } return ChangeLogSet.createEmpty(this); }
AbstractBuild<?, ?> prev = build.getPreviousBuild(); boolean still = false; if (prev != null) { if (prev.getResult() == Result.SUCCESS) { subject = Messages.MailSender_UnstableMail_ToUnStable_Subject(); } else if (prev.getResult() == Result.UNSTABLE) { subject = Messages.MailSender_UnstableMail_StillUnstable_Subject(); still = true; StringBuilder buf = new StringBuilder(); if (still && !(build.getChangeSet().isEmptySet() && prev.getChangeSet().isEmptySet())) { appendUrl(Util.encode(build.getProject().getUrl()) + "changes", buf); } else {
target.setUrl(String.format("%s/%s", this.systemService.getUrl(), source.getUrl())); target.setId(source.getId()); target.setNumber(source.getNumber()); target.setDescription(source.getDescription()); target.setProjectName(source.getProject().getFullName()); for (ChangeLogSet.Entry entry : source.getChangeSet()) { String uid = entry.getAuthor().getId(); if (!participants.contains(uid)) { participants.add(uid); target.setChangesAvailable(source.getChangeSet() != null && !source.getChangeSet().isEmptySet()); target.setTestsAvailable(source.getTestResultAction() != null && source.getTestResultAction().getTotalCount() != 0);
build.getActions().add(action); AbstractBuild upstreamBuild = getBuildByUpstreamCause(build.getCauses(), listener); if(upstreamBuild!= null) { accountableBuilds.add(upstreamBuild); ChangeLogSet<? extends Entry> changeSet = upstreamBuild.getChangeSet(); if(listener != null ) listener.getLogger().append("[ci-game] UpStream Build ID: " + upstreamBuild.getId()+ "\n"); if(listener != null ) listener.getLogger().append("[ci-game] UpStream Display Name: " + upstreamBuild.getFullDisplayName()+ "\n"); if(listener != null ) listener.getLogger().append("[ci-game] Is UpStream Change Set Empty: " + changeSet.isEmptySet() + "\n"); if (changeSet != null) { for (Entry e : changeSet) { players.add(e.getAuthor());
/** * The change log should be based on comparison with the previous build, not * depending on the state of the current local clone. If a workspace is * wiped out, or the build is run on a new slave, it should still result in * the same change log. This test verifies that, by comparing the "normal" * behavior with when the workspace is removed after every build. */ @Bug(10255) @Test public void changelogOnClone() throws Exception { AbstractBuild<?, ?> b; FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), null, null, null, null, false)); m.hg(repo, "init"); m.touchAndCommit(repo, "dir1/f1"); b = p.scheduleBuild2(0).get(); assertTrue(b.getChangeSet().isEmptySet()); b.getWorkspace().deleteRecursive(); // Remove the workspace to force a // re-clone m.touchAndCommit(repo, "dir2/f1"); b = p.scheduleBuild2(0).get(); assertChangeSetPaths( Collections.singletonList(Collections.singleton("dir2/f1")), b); b.getWorkspace().deleteRecursive(); // Remove the workspace to force a // re-clone m.touchAndCommit(repo, "dir3/f1"); b = p.scheduleBuild2(0).get(); assertChangeSetPaths( Collections.singletonList(Collections.singleton("dir3/f1")), b); }
/** * Appends build URL to the builder. * * @param build build. * @param buf {@link StringBuilder}. */ protected void appendBuildUrl(AbstractBuild<?, ?> build, StringBuilder buf) { appendUrl(Util.encode(build.getUrl()) + (build.getChangeSet().isEmptySet() ? "" : "changes"), buf); }
def.setLightweight(false); p.setDefinition(def); WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); r.assertLogContains("Cloning the remote Git repository", b); r.assertLogContains("version one", b); r.assertLogNotContains("Retrying after 10 seconds", b); sampleRepo.write("flow.groovy", "echo 'version two'"); assertEquals(1, changeSets.size()); ChangeLogSet<? extends ChangeLogSet.Entry> changeSet = changeSets.get(0); assertEquals(b, changeSet.getRun()); assertEquals("git", changeSet.getKind()); Iterator<? extends ChangeLogSet.Entry> iterator = changeSet.iterator(); assertTrue(iterator.hasNext()); ChangeLogSet.Entry entry = iterator.next(); assertEquals("[flow.groovy]", entry.getAffectedPaths().toString()); assertFalse(iterator.hasNext());
public EmbedDescription(AbstractBuild build, JenkinsLocationConfiguration globalConfig, String prefix, boolean enableArtifactsList) { String artifactsURL = globalConfig.getUrl() + build.getUrl() + "artifact/"; this.prefix = prefix; this.changesList.add("\n**Changes:**\n"); if (enableArtifactsList) this.artifactsList.add("\n**Artifacts:**\n"); Object[] changes = build.getChangeSet().getItems(); for (Object o : changes) { ChangeLogSet.Entry entry = (ChangeLogSet.Entry) o; String commitID = (entry.getParent().getKind().equalsIgnoreCase("svn")) ? entry.getCommitId() : entry.getCommitId().substring(0, 6); this.changesList.add(" - ``" + commitID + "`` *" + entry.getMsg() + " - " + entry.getAuthor().getFullName() + "*\n"); List<Run.Artifact> artifacts = build.getArtifacts(); if (artifacts.size() == 0) { this.artifactsList.add("\n*No artifacts saved.*");
@Test public void changelogIsDisabled() throws Exception { AbstractBuild<?, ?> b; FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), MercurialSCM.RevisionType.BRANCH, null, null, null, null, false, null, true)); m.hg(repo, "init"); m.touchAndCommit(repo, "dir1/f1"); b = p.scheduleBuild2(0).get(); assertTrue(b.getChangeSet().isEmptySet()); m.touchAndCommit(repo, "dir2/f1"); b = p.scheduleBuild2(0).get(); assertTrue(b.getChangeSet().isEmptySet()); } }
@Override public String buildCompletionMessage(IMPublisher publisher, AbstractBuild<?, ?> build, BuildListener listener) throws IOException, InterruptedException { StringBuilder sb = new StringBuilder(super.buildCompletionMessage(publisher,build,listener)); if (!build.getChangeSet().isEmptySet()) { boolean hasManyChangeSets = build.getChangeSet().getItems().length > 1; for (Entry entry : build.getChangeSet()) { sb.append("\n"); if (hasManyChangeSets) { sb.append("* "); } sb.append(entry.getAuthor()).append(": ").append(entry.getMsg()); } } return sb.toString(); }
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false))); WorkflowJob p = WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject(mp, "master"); j.waitUntilNoActivity(); j.assertBuildStatus(Result.FAILURE, j.waitForCompletion(failing)); assertEquals(1, failing.getChangeSets().size()); ChangeLogSet<? extends ChangeLogSet.Entry> failingChanges = failing.getChangeSets().get(0); assertEquals(1, failingChanges.getItems().length); ChangeLogSet.Entry failingEntry = failingChanges.iterator().next(); assertNotNull(failingEntry); assertEquals(1, b3.getChangeSets().size()); ChangeLogSet<? extends ChangeLogSet.Entry> b3Changes = failing.getChangeSets().get(0); assertEquals(1, b3Changes.getItems().length); ChangeLogSet.Entry b3Entry = b3Changes.iterator().next(); assertNotNull(b3Entry); assertEquals(failingEntry.getCommitId(), b3Entry.getCommitId());
@Test public void changelogFromPreviousBuild() throws Exception { AbstractBuild<?, ?> b; FreeStyleProject p = j.createFreeStyleProject(); Slave s1 = j.createOnlineSlave(); Slave s2 = j.createOnlineSlave(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), null, null, null, null, false)); m.touchAndCommit(repo, "dir1/f1"); b = p.scheduleBuild2(0).get(); assertTrue(b.getChangeSet().isEmptySet()); p.setAssignedNode(s2); m.touchAndCommit(repo, "dir2/f1");
@Override @Exported public synchronized List<ChangeLogSet<? extends ChangeLogSet.Entry>> getChangeSets() { if (changeSets == null) { changeSets = new ArrayList<>(); for (SCMCheckout co : checkouts(null)) { if (co.changelogFile != null && co.changelogFile.isFile()) { try { ChangeLogSet<? extends ChangeLogSet.Entry> changeLogSet = co.scm.createChangeLogParser().parse(this, co.scm.getEffectiveBrowser(), co.changelogFile); if (!changeLogSet.isEmptySet()) { changeSets.add(changeLogSet); } } catch (Exception x) { LOGGER.log(Level.WARNING, "could not parse " + co.changelogFile, x); } } } } return changeSets; }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") public Iterator<T> iterator() { return isEmptySet()? Iterators.<T>emptyIterator(): getLogs().iterator(); }
private void setContent() { if (build.getChangeSet().getItems().length == 0) { message.setContent(this.getResultString()); } else { StringBuilder changes = new StringBuilder(); for (Iterator<? extends ChangeLogSet.Entry> i = build.getChangeSet().iterator(); i.hasNext(); ) { ChangeLogSet.Entry change = i.next(); changes.append("\n"); changes.append(change.getMsg()); changes.append(" - "); changes.append(change.getAuthor()); } message.setContent(String.format("%s%n%s", this.getResultString(), changes.toString())); } }
public void add(String scmClass, String scmFriendlyName, ChangeLogSet<? extends Entry> cls) { if(!cls.isEmptySet()) { ChangeLogSetWrapper wrapper = changes.get(scmClass); if(wrapper == null) { wrapper = new ChangeLogSetWrapper(build, cls.getBrowser(), scmFriendlyName, cls.getClass()); changes.put(scmClass, wrapper); } wrapper.addChanges(cls); } kinds.add(cls.getKind()); }
@Override public ChangeLogSet<? extends ChangeLogSet.Entry> parse(Run build, RepositoryBrowser<?> browser, File changelogFile) throws IOException, SAXException { return ChangeLogSet.createEmpty(build); }
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(); }