hudson.scm.ChangeLogSet Java Examples

The following examples show how to use hudson.scm.ChangeLogSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildCulpritsWorkflowRun.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
protected Set<String> getCommittersForRun(Run<?, ?> run) {
    WorkflowRun workflowRun = (WorkflowRun) run;
    Set<String> committers = new TreeSet<String>();
    for (ChangeLogSet<? extends ChangeLogSet.Entry> changeLogSet : workflowRun.getChangeSets()) {
        Iterables
            .addAll(committers, transform(nonNullIterable(changeLogSet), new Function<ChangeLogSet.Entry, String>
                () {
                @Override
                public String apply(@Nullable ChangeLogSet.Entry entry) {
                    return entry != null ? entry.getAuthor().getFullName() : null;
                }
            }));
    }
    return committers;
}
 
Example #2
Source File: ChangeSetResourceTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void testChangeSet(){
    Reachable reachable = mock(Reachable.class);
    when(reachable.getLink()).thenReturn(new Link("/foo/bar"));
    User user = mock(User.class);
    when(user.getId()).thenReturn("vivek");
    ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
    when(entry.getAuthor()).thenReturn(user);
    when(entry.getTimestamp()).thenReturn(System.currentTimeMillis());
    when(entry.getCommitId()).thenReturn("12345");
    when(entry.getMsg()).thenReturn("test changeset");
    when(entry.getAffectedPaths()).thenReturn(Collections.singleton("/foo/bar"));
    ChangeSetResource changeSetResource = new ChangeSetResource(new OrganizationImpl("testorg", mock(Folder.class)), entry, reachable);
    assertEquals(user.getId(), changeSetResource.getAuthor().getId());
    assertEquals(entry.getCommitId(), changeSetResource.getCommitId());
    assertEquals(entry.getMsg(), changeSetResource.getMsg());
}
 
Example #3
Source File: JiraSCMListenerTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
private static ChangeLogSet build( String... texts) {
    List<ChangeLogSet.Entry> entries = Arrays.asList( texts ).stream().map( text -> {
        final ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
        when(entry.getMsg()).thenReturn(text);
        return  entry;
    } ).collect( Collectors.toList() );

    return new ChangeLogSet<ChangeLogSet.Entry>(null, null) {
        @Override
        public boolean isEmptySet() {
            return false;
        }

        @Override
        public Iterator<Entry> iterator() {
            return entries.iterator();
        }
    };
}
 
Example #4
Source File: BlueIssueFactory.java    From blueocean-plugin with MIT License 6 votes vote down vote up
/**
 * Finds any issues associated with the changeset
 * e.g. a commit message could be "TICKET-123 fix all the things" and be associated with TICKET-123 in JIRA
 * @param changeSetEntry entry
 * @return issues representing the change
 */
public static Collection<BlueIssue> resolve(ChangeLogSet.Entry changeSetEntry) {
    LinkedHashSet<BlueIssue> allIssues = Sets.newLinkedHashSet();
    for (BlueIssueFactory factory : ExtensionList.lookup(BlueIssueFactory.class)) {
        try {
            Collection<BlueIssue> issues = factory.getIssues(changeSetEntry);
            if (issues == null) {
                continue;
            }
            allIssues.addAll(issues);
        } catch (Exception e) {
            LOGGER.log(Level.WARNING,"Unable to fetch issues for changeSetEntry " + e.getMessage(), e);
        }
    }
    return allIssues;
}
 
Example #5
Source File: BuildNotifier.java    From build-notifications-plugin with MIT License 6 votes vote down vote up
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()));
  }
}
 
Example #6
Source File: GithubIssue.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Override
public Collection<BlueIssue> getIssues(ChangeLogSet.Entry changeSetEntry) {
    Job job = changeSetEntry.getParent().getRun().getParent();
    if (!(job.getParent() instanceof MultiBranchProject)) {
        return null;
    }
    MultiBranchProject mbp = (MultiBranchProject)job.getParent();
    List<SCMSource> scmSources = (List<SCMSource>) mbp.getSCMSources();
    SCMSource source = scmSources.isEmpty() ? null : scmSources.get(0);
    if (!(source instanceof GitHubSCMSource)) {
        return null;
    }
    GitHubSCMSource gitHubSource = (GitHubSCMSource)source;
    String apiUri =  gitHubSource.getApiUri();
    final String repositoryUri = new HttpsRepositoryUriResolver().getRepositoryUri(apiUri, gitHubSource.getRepoOwner(), gitHubSource.getRepository());
    Collection<BlueIssue> results = new ArrayList<>();
    for (String input : findIssueKeys(changeSetEntry.getMsg())) {
        String uri = repositoryUri.substring(0, repositoryUri.length() - 4);
        results.add(new GithubIssue("#" + input, String.format("%s/issues/%s", uri, input)));
    }
    return results;
}
 
Example #7
Source File: FactsBuilder.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
public void addDevelopers() {
    if (!(run instanceof RunWithSCM)) {
        return;
    }
    RunWithSCM runWithSCM = (RunWithSCM) run;

    List<ChangeLogSet<ChangeLogSet.Entry>> sets = runWithSCM.getChangeSets();

    Set<User> authors = new HashSet<>();
    sets.stream()
            .filter(set -> set instanceof ChangeLogSet)
            .forEach(set -> set
                    .forEach(entry -> authors.add(entry.getAuthor())));

    addFact(NAME_DEVELOPERS, StringUtils.join(sortUsers(authors), ", "));
}
 
Example #8
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleCase()
        throws Exception
{
    List<ChangeLogSet.Entry> validChanges = Arrays.asList(
            MockChangeLogUtil.mockChangeLogSetEntry("Hello World [FOO-101]"),
            MockChangeLogUtil.mockChangeLogSetEntry("FOO-101 ticket at start"),
            MockChangeLogUtil.mockChangeLogSetEntry("In the middle FOO-101 of the message"),
            MockChangeLogUtil.mockChangeLogSetEntry("Weird characters FOO-101: next to it"));
    for (ChangeLogSet.Entry change : validChanges)
    {
        assertThat(strategy.getJiraIssuesFromChangeSet(change).size(), equalTo(1));
        assertThat(strategy.getJiraIssuesFromChangeSet(change).get(0).getJiraTicket(), equalTo("FOO-101"));
    }

}
 
Example #9
Source File: ZulipNotifier.java    From zulip-plugin with MIT License 6 votes vote down vote up
private String getChangeSet(Run<?, ?> build) {
    StringBuilder changeString = new StringBuilder();
    RunChangeSetWrapper wrapper = new RunChangeSetWrapper(build);
    if (!wrapper.hasChangeSetComputed()) {
        changeString.append("Could not determine changes since last build.");
    } else if (wrapper.hasChangeSet()) {
        // If there seems to be a commit message at all, try to list all the changes.
        changeString.append("Changes since last build:\n");
        for (ChangeLogSet<? extends ChangeLogSet.Entry> changeLogSet : wrapper.getChangeSets()) {
            for (ChangeLogSet.Entry e : changeLogSet) {
                String commitMsg = e.getMsg().trim();
                if (commitMsg.length() > 47) {
                    commitMsg = commitMsg.substring(0, 46) + "...";
                }
                String author = e.getAuthor().getDisplayName();
                changeString.append("\n* `").append(author).append("` ").append(commitMsg);
            }
        }
    }
    return changeString.toString();
}
 
Example #10
Source File: FactsBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void addDevelopers_AddsFactWithSortedAuthors() {

    // given
    List<ChangeLogSet> files = new AffectedFileBuilder().sampleChangeLogs(run);
    when(run.getChangeSets()).thenReturn(files);

    FactsBuilder factBuilder = new FactsBuilder(run, taskListener);

    // when
    factBuilder.addDevelopers();

    // then
    String[] sortedAuthors = {AffectedFileBuilder.sampleAuthors[2], AffectedFileBuilder.sampleAuthors[1], AffectedFileBuilder.sampleAuthors[0]};
    FactAssertion.assertThat(factBuilder.collect())
            .hasName(FactsBuilder.NAME_DEVELOPERS)
            .hasValue(StringUtils.join(sortedAuthors, ", "));
}
 
Example #11
Source File: BlueJiraIssue.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Override
public Collection<BlueIssue> getIssues(ChangeLogSet.Entry changeSetEntry) {
    Run run = changeSetEntry.getParent().getRun();
    final JiraSite site = JiraSite.get(run.getParent());
    if (site == null) {
        return null;
    }
    final JiraBuildAction action = run.getAction(JiraBuildAction.class);
    if (action == null) {
        return null;
    }
    Collection<String> issueKeys = findIssueKeys(changeSetEntry.getMsg(), site.getIssuePattern());
    Iterable<BlueIssue> transformed = Iterables.transform(issueKeys,
                                                          s -> BlueJiraIssue.create(site, action.getIssue(s)));
    return ImmutableList.copyOf(Iterables.filter(transformed, Predicates.notNull()));
}
 
Example #12
Source File: ChangeLogExtractorTest.java    From atlassian-jira-software-cloud-plugin with Apache License 2.0 6 votes vote down vote up
private WorkflowRun workflowRunWithIssuesAboveLimit() {
    int count = 105;
    Object[] changeSetEntries = new Object[count];
    for (int i = 0; i < count; i++) {
        final ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
        when(entry.getMsg()).thenReturn(String.format("TEST-%d Commit message for %d", i, i));
        changeSetEntries[i] = entry;
    }
    final ChangeLogSet changeLogSet = mock(ChangeLogSet.class);

    when(changeLogSet.getItems()).thenReturn(changeSetEntries);
    final WorkflowRun workflowRun = mock(WorkflowRun.class);

    when(workflowRun.getChangeSets()).thenReturn(ImmutableList.of(changeLogSet));
    return workflowRun;
}
 
Example #13
Source File: GithubIssueTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void changeSetEntryIsNotGithub() throws Exception {
    MultiBranchProject project = mock(MultiBranchProject.class);
    Job job = mock(MockJob.class);
    Run run = mock(Run.class);
    ChangeLogSet logSet = mock(ChangeLogSet.class);
    ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);

    when(project.getProperties()).thenReturn(new DescribableList(project));
    when(entry.getParent()).thenReturn(logSet);
    when(logSet.getRun()).thenReturn(run);
    when(run.getParent()).thenReturn(job);
    when(job.getParent()).thenReturn(project);

    when(entry.getMsg()).thenReturn("Closed #123 #124");
    when(project.getSCMSources()).thenReturn(Lists.newArrayList(new GitSCMSource("http://example.com/repo.git")));

    Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
    Assert.assertEquals(0, resolved.size());
}
 
Example #14
Source File: ChangelogReader.java    From fabric-beta-publisher-plugin with MIT License 6 votes vote down vote up
static ChangeLogSet<? extends ChangeLogSet.Entry> getChangeLogSet(Run<?, ?> build) {
    if (build instanceof AbstractBuild) {
        return ((AbstractBuild<?, ?>) build).getChangeSet();
    }
    ItemGroup<?> itemGroup = build.getParent().getParent();
    for (Item item : itemGroup.getItems()) {
        if (!item.getFullDisplayName().equals(build.getFullDisplayName())
                && !item.getFullDisplayName().equals(build.getParent().getFullDisplayName())) {
            continue;
        }

        for (Job<?, ?> job : item.getAllJobs()) {
            if (job instanceof AbstractProject<?, ?>) {
                AbstractProject<?, ?> project = (AbstractProject<?, ?>) job;
                return project.getBuilds().getLastBuild().getChangeSet();
            }
        }
    }
    return ChangeLogSet.createEmpty(build);
}
 
Example #15
Source File: FirstWordOfCommitStrategy.java    From jira-ext-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Parse a Jira ticket number, ie SSD-101, out of the given ChangeLogSet.Entry.
 *
 * Ticket number is assumed to be the first word of the commit message
 *
 * @param change - the change entry to
 * @return
 */
@Override
public List<JiraCommit> getJiraIssuesFromChangeSet(final ChangeLogSet.Entry change)
{
    String msg = change.getMsg();
    String firstWordOfTicket;
    firstWordOfTicket = msg.substring(0, (msg.contains(" ") ? StringUtils.indexOf(msg, " ") : msg.length()));

    final String regex = "([A-Z][0-9A-Z_]+-)([0-9]+)";
    final Pattern pattern = Pattern.compile(regex);
    final Matcher matcher = pattern.matcher(firstWordOfTicket);

    if (!matcher.find())
    {
        return null;
    }

    List<String> jiraPrefixes = Config.getGlobalConfig().getJiraTickets();

    if (jiraPrefixes.contains(matcher.group(1)))
    {
        return Arrays.asList(new JiraCommit(matcher.group(0), change));
    }

    return null;
}
 
Example #16
Source File: GithubIssueTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void changeSetJobParentNotMultibranch() throws Exception {
    AbstractFolder project = mock(AbstractFolder.class);
    Job job = mock(MockJob.class);
    Run run = mock(Run.class);
    ChangeLogSet logSet = mock(ChangeLogSet.class);
    ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);

    when(project.getProperties()).thenReturn(new DescribableList(project));
    when(entry.getParent()).thenReturn(logSet);
    when(logSet.getRun()).thenReturn(run);
    when(run.getParent()).thenReturn(job);
    when(job.getParent()).thenReturn(project);

    when(entry.getMsg()).thenReturn("Closed #123 #124");

    Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
    Assert.assertEquals(0, resolved.size());
}
 
Example #17
Source File: BuildStateRecipe.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private BuildStateRecipe withChangesFromForJenkins2_46(String... authors) {
    ChangeLogSet changeSet = changeSetBasedOn(entriesBy(authors));
    when(build.getChangeSet()).thenReturn(changeSet);

    // any methods that use getChangeSet as their source of data should be called normally
    // (build is a partial mock in this case)
    when(build.getCulprits()).thenCallRealMethod();

    return this;
}
 
Example #18
Source File: FirstWordOfCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testFirstWordOfCommit()
        throws Exception
{
    FirstWordOfCommitStrategy strategy = new FirstWordOfCommitStrategy();

    ChangeLogSet mockChangeSet = MockChangeLogUtil.mockChangeLogSet(
            new MockChangeLogUtil.MockChangeLog("FOO-101 first", "dalvizu"),
            new MockChangeLogUtil.MockChangeLog("BAR-102 again", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("BAR-103: third", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("[BAR-104] fourth", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("[BAR-105][section] fifth", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("[BAR-106]: sixth", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("MY_EXAMPLE_PROJECT-107 seventh", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("2013PROJECT-108 eighth", "jsmith"),
            new MockChangeLogUtil.MockChangeLog("No Valid Ticket", "build robot"));
    AbstractBuild mockBuild = mock(AbstractBuild.class);
    when(mockBuild.getChangeSet()).thenReturn(mockChangeSet);
    List<JiraCommit> commits = strategy.getJiraCommits(mockBuild,
            new StreamBuildListener(System.out, Charset.defaultCharset()));
    assertEquals(commits.size(), 7);

    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-101"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-102"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-103"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-104"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-105"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-106"))));
    assertThat(commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("MY_EXAMPLE_PROJECT-107"))));
    assertThat(commits, is(not(hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("2013PROJECT-108"))))));
}
 
Example #19
Source File: BuildStateRecipe.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private BuildStateRecipe withChangesFromForJenkins2_107AndNewer(String... authors) throws Exception {
    ChangeLogSet changeSet = changeSetBasedOn(entriesBy(authors));
    when(build.getChangeSet()).thenReturn(changeSet);
    PowerMockito.doReturn(true).when(build, "shouldCalculateCulprits");

    // any methods that use getChangeSet as their source of data should be called normally
    // (build is a partial mock in this case)
    when(build.getChangeSets()).thenCallRealMethod();
    when(build.getCulprits()).thenCallRealMethod();
    PowerMockito.doCallRealMethod().when(build, "calculateCulprits");

    return this;
}
 
Example #20
Source File: BuildCulpritsAbstractBuild.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
protected Set<String> getCommittersForRun(Run<?, ?> run) {
    AbstractBuild<?, ?> abstractBuild = (AbstractBuild<?, ?>) run;
    Set<String> committers = new TreeSet<String>();
    Iterable<String> iterable = transform(nonNullIterable(((AbstractBuild<?, ?>) abstractBuild)
        .getChangeSet()), new Function<ChangeLogSet.Entry, String>() {
        @Override
        public String apply(ChangeLogSet.Entry entry) {
            return entry.getAuthor().getFullName();
        }
    });
    Iterables.addAll(committers, iterable);
    return committers;
}
 
Example #21
Source File: BuildStateRecipe.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
private List<ChangeLogSet.Entry> entriesBy(String... authors) {
    List<ChangeLogSet.Entry> entries = new ArrayList<ChangeLogSet.Entry>();

    for (String name : authors) {
        User author = mock(User.class);
        ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);

        when(author.getFullName()).thenReturn(name);
        when(entry.getAuthor()).thenReturn(author);

        entries.add(entry);
    }
    return entries;
}
 
Example #22
Source File: RunChangeSetWrapper.java    From zulip-plugin with MIT License 5 votes vote down vote up
public List<? extends ChangeLogSet<? extends ChangeLogSet.Entry>> getChangeSets() {
    if (build instanceof AbstractBuild) {
        return Collections.singletonList(((AbstractBuild<?, ?>) build).getChangeSet());
    } else if (build instanceof WorkflowRun) {
        return ((WorkflowRun) build).getChangeSets();
    }
    return null;
}
 
Example #23
Source File: AddComment.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
private String buildComment(Optional<ChangeLogSet.Entry> change,
                            EnvVars environment)
{
    String finalComment = commentText;
    finalComment = environment.expand(finalComment);

    if (!change.isPresent())
    {
        return finalComment;
    }

    String message = "";
    ChangeLogSet.Entry entry = change.get();
    if (entry instanceof GitChangeSet)
    {
        message = ((GitChangeSet) entry).getComment();
    }
    else
    {
        message = entry.getMsg();
    }

    finalComment = StringUtils.replace(finalComment, "$AUTHOR", (entry.getAuthor() == null ? "null" : entry.getAuthor().getDisplayName()));
    finalComment = StringUtils.replace(finalComment, "$COMMIT_ID", entry.getCommitId());
    finalComment = StringUtils.replace(finalComment, "$COMMIT_DATE",
            DATE_FORMAT.format(new Date(entry.getTimestamp())));
    finalComment = StringUtils.replace(finalComment, "$COMMIT_MESSAGE", message);
    return finalComment;
}
 
Example #24
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetJiraTicketsFromChangeSet() {

    String message = "First line of commit. Changed some things.";
    StringBuilder stringBuilder = new StringBuilder();
    String comment = stringBuilder.append(message)
            .append("Changed some other stuff")
            .append("\n")
            .append("See ticket FOO-101")
            .toString();
     ChangeLogSet.Entry entry = MockChangeLogUtil.mockGitCommit(message, comment);
     assertThat(strategy.getJiraIssuesFromChangeSet(entry).size(), equalTo(1));
    assertThat(strategy.getJiraIssuesFromChangeSet(entry),
            hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-101"))));
}
 
Example #25
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testJenkins33856()
{
    ChangeLogSet.Entry entry = MockChangeLogUtil.mockChangeLogSetEntry("Testing JIRA (ticket with a few spaces at the end and no EOL) FOO-141   ");
    assertThat(strategy.getJiraIssuesFromChangeSet(entry).size(), equalTo(1));
    assertThat(strategy.getJiraIssuesFromChangeSet(entry),
            hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-141"))));
}
 
Example #26
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testTicketRepeatsItself()
{
    ChangeLogSet.Entry entry = MockChangeLogUtil.mockChangeLogSetEntry("FOO-101 is in the message twice FOO-101");
    assertThat(strategy.getJiraIssuesFromChangeSet(entry).size(), equalTo(1));
    assertThat(strategy.getJiraIssuesFromChangeSet(entry),
            hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-101"))));
}
 
Example #27
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipleTicketNames()
{
    ChangeLogSet.Entry entry = MockChangeLogUtil.mockChangeLogSetEntry("FOO-101 and\n BAR-101 are both in the message");
    assertThat(strategy.getJiraIssuesFromChangeSet(entry).size(), equalTo(2));
    assertThat(strategy.getJiraIssuesFromChangeSet(entry),
            hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-101"))));
    assertThat(strategy.getJiraIssuesFromChangeSet(entry),
            hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-101"))));
}
 
Example #28
Source File: MentionedInCommitStrategyTest.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testNotFound()
        throws Exception
{
    ChangeLogSet.Entry entry = MockChangeLogUtil.mockChangeLogSetEntry("SSD-101 test");
    assertThat(strategy.getJiraIssuesFromChangeSet(entry).size(), equalTo(0));
}
 
Example #29
Source File: JiraCommit.java    From jira-ext-plugin with Apache License 2.0 5 votes vote down vote up
public JiraCommit(String jiraTicket, ChangeLogSet.Entry changeSet)
{
    this.jiraTicket = jiraTicket;
    if (changeSet == null)
    {
        this.changeSet = Optional.absent();
    }
    else
    {
        this.changeSet = Optional.of(changeSet);
    }
}
 
Example #30
Source File: ReleaseNotesFormatter.java    From fabric-beta-publisher-plugin with MIT License 5 votes vote down vote up
static String getReleaseNotes(ChangeLogSet<? extends ChangeLogSet.Entry> changeLogSet, String releaseNotesType,
                              String releaseNotesParameter, String releaseNotesFile, EnvVars environment,
                              FilePath workspace)
        throws IOException, InterruptedException {
    switch (releaseNotesType) {
        case RELEASE_NOTES_TYPE_NONE:
            return null;
        case RELEASE_NOTES_TYPE_PARAMETER:
            return environment.get(releaseNotesParameter, "");
        case RELEASE_NOTES_TYPE_CHANGELOG:
            StringBuilder sb = new StringBuilder();
            if (!changeLogSet.isEmptySet()) {
                boolean hasManyChangeSets = changeLogSet.getItems().length > 1;
                for (ChangeLogSet.Entry entry : changeLogSet) {
                    sb.append("\n");
                    if (hasManyChangeSets) {
                        sb.append("* ");
                    }
                    sb.append(entry.getMsg());
                }
            }
            return sb.toString();
        case RELEASE_NOTES_TYPE_FILE:
            FilePath releaseNotesFilePath = new FilePath(workspace, environment.expand(releaseNotesFile));
            return releaseNotesFilePath.readToString();
        default:
            return null;
    }
}