-
-
Notifications
You must be signed in to change notification settings - Fork 105
[JEP-206] Gather command output in a local encoding #64
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
Conversation
|
|
||
| private boolean returnStdout; | ||
| private String encoding = DurableTaskStepDescriptor.defaultEncoding; | ||
| private String encoding; |
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
svanoort
left a comment
There was a problem hiding this 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?
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 🤷♂️ |
|
and bye-bye @rsandell |
Jenkinsfile
Outdated
| @@ -1 +1 @@ | |||
| buildPlugin(jenkinsVersions: [null, '2.73.1']) | |||
| buildPlugin() | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.107.1 please
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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
🐜
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
|
Test failure looks like a flake. |
|
@svanoort can you check the comments addressing your review ? |
|
@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. |
svanoort
left a comment
There was a problem hiding this 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.
|
@jglick Although I can't tell if that test failure is a flake or actual issue here? |
IIRC there were subsuming PRs which did not fail, strongly suggesting a flake. I can try to retrigger the build. |
[JEP-206] Gather command output in a local encoding
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-jobas well, unless your master happens to be running in UTF-8.