regexIssueTracker not working in CruiseControl.net
I am trying to get an issueUrlBuilder to work in my CruiseControl.NET config, and cannot figure out why they aren't working.
The first one I tried is this:
<cb:define name="issueTracker">
<issueUrlBuilder type="regexIssueTracker">
<find>^.*Issue (\d*).|\n*$</find>
<replace>https://issuetracker/ViewIssue.aspx?ID=$1</replace>
</issueUrlBuilder>
</cb:define>
Then, I reference it in the sourceControl block:
<sourcecontrol type="vaultplugin">
...
<issueTracker/>
</sourcecontrol>
My checkin comments look like this:
[Issue 1234] This is a test comment
I cannot find anywhere in the build reports/logs/etc. where that issue link is converted to a link. Is my regex wrong?
I've also tried the default issueUrlBuilder:
<cb:define name="issueTra开发者_如何学JAVAcker">
<issueUrlBuilder type="defaultIssueTracker">
<url>https://issuetracker/ViewIssue.aspx?ID={0}</url>
</issueUrlBuilder>
</cb:define>
Again, same comments and no links anywhere.
Anyone have any ideas.
It looks like you're trying to match a potentially multiline comment by using .|\n
instead of just .
, which doesn't match newlines by default. Your first problem is that |
has the lowest associativity of all regex constructs, so it's dividing your whole regex into the alternatives ^.*Issue (\d*).
or \n*$
. You would need to enclose the alternation in a group: (?:.|\n)*
.
Another potential problem is that the lines might be separated by \r\n
(carriage-return plus linefeed) instead of just \n
. If CCNET uses the .NET regex engine under the hood, that won't be a problem because the dot matches \r
. But that's not true of all flavors, and anyway, there's always a better way to match anything including newlines than (?:.|\n)*
. I suggest you try
<find>^.*Issue (\d*)(?s:.*)$</find>
or
<find>(?s)^.*Issue (\d*).*$</find>
(?s)
and (?s:...)
are inline modifiers which allow the dot to match line separator characters.
EDIT: It looks like this is a known bug in CCNET. If the inline modifier doesn't work, try replacing .
with [\s\S]
, as you would in a JavaScript regex. Example:
<find>^.*Issue (\d*)[\s\S]*$</find>
精彩评论