Skip to content

Conversation

@jglick
Copy link
Member

@jglick jglick commented Feb 12, 2018

JEP-206

Extracted from #21. Downstream of jenkinsci/durable-task-plugin#61. Also downstream of jenkinsci/workflow-job-plugin#89 for testing, but really as a user you want to update workflow-job as well, unless your master happens to be running in UTF-8.

@jglick jglick mentioned this pull request Feb 13, 2018

private boolean returnStdout;
private String encoding = DurableTaskStepDescriptor.defaultEncoding;
private String encoding;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is a behavioral change—we are changing the default value of encoding from UTF-8 to null (i.e., use the node’s system encoding). Also the encoding now applies to regular streamed output, whereas previously it only mattered for returnStdout: true. (Which is the main point of this whole exercise: JENKINS-31096.)

I tried to think of a way to keep the previous default but it was just going to be ugly. With the change of the overall build log to UTF-8, it would mean that you would get mojibake in case you were running, say, entirely on CP-1252 Windows (with or without agents) and just did something simple like

node {
  bat 'something producing Western European characters…'
}

which seems wrong.

This interpretation of encoding is also consistent with the readFile and writeFile steps, as well as the behavior of freestyle builds (which define the entire build’s log encoding by the node’s system encoding), and I think would be considered most intuitive going forward. Otherwise we would need a special value ('', 'system', …) indicating system default encoding, and then try to explain that in the snippet generator.

Obviously if you have specific knowledge that a given process is going to be producing UTF-8 yet will be running on a node with a different system encoding (typically Windows, since every Linux distribution has defaulted to UTF-8 for a long time), you can make that explicit with encoding: 'UTF-8'.

Copy link
Member

Choose a reason for hiding this comment

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

Obviously if you have specific knowledge that a given process is going to be producing UTF-8 yet will be running on a node with a different system encoding (typically Windows, since every Linux distribution has defaulted to UTF-8 for a long time), you can make that explicit with encoding: 'UTF-8'.

🐛 This should be called out really explicitly in the documentation / UI here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I can emphasize that.

Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable. Whatever is done with encodings in Durable Task and this plugin, it is a risky change anyway. Since the idea is to NOT enforce the UTF encoding, the current approach looks preferable

</pluginRepositories>
<properties>
<jenkins.version>2.60.3</jenkins.version>
<jenkins.version>2.73.3</jenkins.version>
Copy link
Member

Choose a reason for hiding this comment

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

Is this gratuitous or do we need a new API?

Copy link
Member Author

Choose a reason for hiding this comment

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

Test dep on workflow-job requires this.

Copy link
Member

@svanoort svanoort left a comment

Choose a reason for hiding this comment

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

Okay, so help me out here Jesse: is there a way we can execute these PRs so users don't have to update the plugins all in lockstep in order not to result in some mangled output?

Or am I misreading your comments here / in the upstream?

@jglick
Copy link
Member Author

jglick commented Feb 19, 2018

is there a way we can execute these PRs so users don't have to update the plugins all in lockstep in order not to result in some mangled output?

No, as noted elsewhere you need to update both Pipeline: Job and Pipeline: Nodes and Processes. But if you care about Unicode, you probably have mangled output already, so 🤷‍♂️

@jglick jglick requested review from svanoort and removed request for rsandell February 19, 2018 18:59
@jglick
Copy link
Member Author

jglick commented Feb 19, 2018

and bye-bye @rsandell

@svanoort svanoort requested a review from rsandell February 23, 2018 22:17
Jenkinsfile Outdated
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.73.1'])
buildPlugin()
Copy link
Member

Choose a reason for hiding this comment

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

2.107.1 please

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed.

pom.xml Outdated
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.2</version>
<version>3.4</version>
Copy link
Member

Choose a reason for hiding this comment

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

3.6 if 2.107.1 is added to CI

Copy link
Member Author

Choose a reason for hiding this comment

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

Now 3.7.


private boolean returnStdout;
private String encoding = DurableTaskStepDescriptor.defaultEncoding;
private String encoding;
Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable. Whatever is done with encodings in Durable Task and this plugin, it is a risky change anyway. Since the idea is to NOT enforce the UTF encoding, the current approach looks preferable

public static final String defaultEncoding = "UTF-8";

public FormValidation doCheckEncoding(@QueryParameter boolean returnStdout, @QueryParameter String encoding) {
if (encoding.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

StringUtils.isBlank()? otherwise the behavior will differ from Util.fixEmpty
🐜

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a web method; the text field may be blank but not missing.

durableTask.captureOutput();
}
if (step.encoding != null) {
durableTask.charset(Charset.forName(step.encoding));
Copy link
Member

Choose a reason for hiding this comment

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

Catch/rethrow exception with more debug details?

Copy link
Member Author

Choose a reason for hiding this comment

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

Which debug details are you looking for here?

@jglick
Copy link
Member Author

jglick commented Jun 11, 2018

Test failure looks like a flake.

@carlossg
Copy link

@svanoort can you check the comments addressing your review ?

@svanoort
Copy link
Member

@carlossg I'm mostly booked up for the week due to the Java 10 hackathon, but will take a look as soon as we're out of that, thanks.

@jglick jglick requested a review from dwnusbaum June 22, 2018 21:38
Copy link
Member

@svanoort svanoort left a comment

Choose a reason for hiding this comment

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

AFAICT this is fine -- although we'll probably have some issues from the incompatible aspects of this, at least it moves in the right direction.

@svanoort
Copy link
Member

@jglick Although I can't tell if that test failure is a flake or actual issue here?

@jglick
Copy link
Member Author

jglick commented Jul 17, 2018

I can't tell if that test failure is a flake or actual issue

IIRC there were subsuming PRs which did not fail, strongly suggesting a flake. I can try to retrigger the build.

@jglick jglick closed this Jul 17, 2018
@jglick jglick reopened this Jul 17, 2018
@jglick jglick changed the title [JENKINS-31096] Gather command output in a local encoding [JEP-206] Gather command output in a local encoding Aug 6, 2018
@svanoort svanoort merged commit 0220678 into jenkinsci:master Aug 7, 2018
@jglick jglick deleted the UTF-8-JENKINS-31096 branch August 7, 2018 21:54
orgi pushed a commit to orgi/workflow-durable-task-step-plugin that referenced this pull request Nov 13, 2018
[JEP-206] Gather command output in a local encoding
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.

6 participants