Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Build Log Excerpt Macro Start/End Order #23

Merged
merged 1 commit into from
Sep 10, 2016

Conversation

nwinkler
Copy link
Contributor

@nwinkler nwinkler commented Sep 6, 2016

The current version of the code has an issue when the end pattern is
matched before the start pattern was found - it simply stops parsing
the log file. This is an issue in case the end pattern appears in the
log multiple times (including before the start pattern), e.g.

Log 1
Log 2
sleep 5
Log 3
Log 4
Run Test
Log 5
Log 6
sleep 5
Log 7
Log 8

If I use the following macro:

${BUILD_LOG_EXCERPT, start="Run Test", end="sleep 5"}

then the current version of the code prints an empty excerpt, since it
stops evaluating the log when it finds the first occurence of sleep 5.
This feels strange, and caused me a couple of lost hours, since I was
trying to figure out why it didn't print anything. Looking at the code,
I found this issue, and have made a small change that ensures that the
end pattern is only checked once the start pattern has been found.

I hope this is fine, but to me it makes a lot more sense like that. I've
also added a unit test to verify that the fix works.

The current version of the code has an issue when the `end` pattern is
matched before the `start` pattern was found - it simply stops parsing
the log file. This is an issue in case the `end` pattern appears in the
log multiple times (including before the `start` pattern), e.g.

```
Log 1
Log 2
sleep 5
Log 3
Log 4
Run Test
Log 5
Log 6
sleep 5
Log 7
Log 8
```

If I use the following macro:

```
${BUILD_LOG_EXCERPT, start="Run Test", end="sleep 5"}
```

then the current version of the code prints an empty excerpt, since it
stops evaluating the log when it finds the first occurence of `sleep 5`.
This feels strange, and caused me a couple of lost hours, since I was
trying to figure out why it didn't print anything. Looking at the code,
I found this issue, and have made a small change that ensures that the
`end` pattern is only checked once the `start` pattern has been found.

I hope this is fine, but to me it makes a lot more sense like that. I've
also added a unit test to verify that the fix works.
@slide
Copy link
Member

slide commented Sep 9, 2016

Closing and reopening to get a build.

@slide slide closed this Sep 9, 2016
@slide slide reopened this Sep 9, 2016
@slide slide merged commit d02c055 into jenkinsci:master Sep 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants