Skip to content

Commit

Permalink
JENKINS-43964 Remove square brackets from Jenkins comment replier.
Browse files Browse the repository at this point in the history
The square brackets generated interfere with JIRA wiki syntax which
causes multiple job URLs to be combined to one link.

Before: Build is scheduled for: [http://jenkins.url, http://jenkins.url]
After: Build is scheduled for: http://jenkins.url, http://jenkins.url
  • Loading branch information
ceilfors committed Apr 24, 2018
1 parent dd446ce commit fed5539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Expand Up @@ -14,7 +14,7 @@ import org.junit.rules.TestWatcher
import org.junit.runner.Description
import spock.lang.Specification

import static JiraCommentTrigger.DEFAULT_COMMENT
import static com.ceilfors.jenkins.plugins.jiratrigger.JiraCommentTrigger.DEFAULT_COMMENT
import static com.ceilfors.jenkins.plugins.jiratrigger.integration.FakeJiraRunner.CUSTOM_FIELD_NAME

/**
Expand Down Expand Up @@ -86,6 +86,7 @@ class JiraTriggerAcceptanceTest extends Specification {

def "Should reply back to JIRA when a build is scheduled"() {
given:
def expectedComment
jenkins.quietPeriod = 100
String issueKey = jira.createIssue()
def project = jenkins.createJiraCommentTriggeredProject('job')
Expand All @@ -95,10 +96,19 @@ class JiraTriggerAcceptanceTest extends Specification {

when:
jenkins.setJiraCommentReply(true)
expectedComment = "Build is scheduled for: ${project.absoluteUrl}"
jira.addComment(issueKey, DEFAULT_COMMENT)

then:
1 * jiraClient.addComment(issueKey, { it ==~ "Build is scheduled for: \\[${project.absoluteUrl}\\]" })
1 * jiraClient.addComment(issueKey, { it ==~ expectedComment })

when:
def project2 = jenkins.createJiraCommentTriggeredProject('job2')
expectedComment = "Build is scheduled for: ${project.absoluteUrl}, ${project2.absoluteUrl}"
jira.addComment(issueKey, DEFAULT_COMMENT)

then:
1 * jiraClient.addComment(issueKey, { it ==~ expectedComment })
}

def 'Should map parameters to the triggered build when a comment is created'() {
Expand Down
Expand Up @@ -19,7 +19,7 @@ class JiraCommentReplier implements JiraTriggerListener {
@Override
void buildScheduled(Issue issue, Collection<? extends AbstractProject> projects) {
if (jiraTriggerGlobalConfiguration.jiraCommentReply) {
jiraClient.addComment(issue.key, 'Build is scheduled for: ' + projects*.absoluteUrl)
jiraClient.addComment(issue.key, 'Build is scheduled for: ' + projects*.absoluteUrl.join(', '))
}
}

Expand Down

0 comments on commit fed5539

Please sign in to comment.