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

[JENKINS-54133] Pregenerating console notes sent to agents for some common cases #128

Merged
merged 2 commits into from
Nov 1, 2018

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 30, 2018

JENKINS-54133. Does not attempt to pregenerate notes for all cases, and in fact this seems to be impossible, though more common cases could certainly be added as needed.

As noted in JIRA, reimplementing the plugin as a ConsoleAnnotatorFactory would be a better solution in many respects, as well as fully solving this issue, but this would be a more ambitious refactoring than I am prepared to take on at the moment as it would involve inverting the control flow of AnsiOutputStream. See the corresponding Blue Ocean jenkinsci/blueocean-plugin#1325 for a very general idea.

@@ -45,23 +46,51 @@
</distributionManagement>

<properties>
<jenkins.version>1.642.3</jenkins.version>
<jenkins.version>2.121.2</jenkins.version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to stats this is not a big deal, even if there are active trunk releases of this plugin for unrelated changes.

But, if baseline is an obstacle, the POM changes could be reverted. In that case the only src/main/ change would be to convert some uses of lambdas to inner classes, pretty simple; the src/test/ code could remain, but would no longer reproduce the problem unless run under plugin-compat-tester.

for (AnsiColorMap.Color color : AnsiColorMap.Color.values()) {
pregenerateNote(new AnsiAttributeElement(AnsiAttributeElement.AnsiAttrType.FG, "span", "style=\"color: " + colorMap.getNormal(color.ordinal()) + ";\""));
}
// TODO other cases, and other methods
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tedious part. Handling bright colors, swapColors, bold/italic/underline, etc. Basically every call to the AnsiAttributeElement constructor from AnsiHtmlOutputStream which could be predicted given an AnsiColorMap—probably all but the explicit use of RGB coördinates, which I am guessing are rarely used anyway.


private void pregenerateNote(String html) {
if (!notes.containsKey(html)) {
JenkinsJVM.checkJenkinsJVM();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See jenkinsci/ant-plugin#32 for a simpler patch that illustrates the idiom.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and it's easy enough to add more cases, although I don't know what would be most commonly used. I did a quick test locally and it seems like the addition of AnsiAttrType.BOLD would handle all of the ANSI sequence that Maven uses, so maybe it would be good to add that one as well.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. See a note on test.

Please update https://github.com/jenkinsci/ansicolor-plugin/blob/master/CHANGELOG.md, too.

WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"node {\n"
"node('!master') {\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like this should be a separate test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed unnecessary as AnsiColorStepTest already tests the behavior on master.

@dblock
Copy link
Member

dblock commented Oct 30, 2018

@jglick We could also use another maintainer here, let us know if you're interested.

@jglick
Copy link
Member Author

jglick commented Nov 1, 2018

We could also use another maintainer here, let us know if you're interested.

Sorry, I could not commit to that.

@jglick
Copy link
Member Author

jglick commented Nov 1, 2018

maybe it would be good to add [AnsiAttrType.BOLD] as well

Probably. I was reluctant to get into cases for which there is no automated test coverage. It is possible the relevant parts of AnsiHtmlOutputStreamTest could be reworked to provide coverage for the AnsiColorConsoleLogFilter constructor in a separate test suite, with most cases initially @Ignored.

@dblock dblock merged commit e854a4c into jenkinsci:master Nov 1, 2018
@dblock
Copy link
Member

dblock commented Nov 1, 2018

Merged, thanks.

@jglick jglick deleted the remote-console-notes-JENKINS-54133 branch November 1, 2018 16:01
@dwnusbaum dwnusbaum mentioned this pull request Nov 5, 2018
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.

3 participants