-
Notifications
You must be signed in to change notification settings - Fork 96
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
Final line of shell output without newline lost when using LineTransformationOutputStream-based decorators #112
Conversation
@@ -132,7 +132,7 @@ | |||
<dependency> | |||
<groupId>org.jenkins-ci.plugins</groupId> | |||
<artifactId>credentials-binding</artifactId> | |||
<version>1.16</version> | |||
<version>1.17</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.
To pick up jenkinsci/credentials-binding-plugin#51. This seems to be the reason that, in watch mode, the test was previously failing (output was getting lost) even in situations that did not involve a missing final newline.
It is a bit scary, however, and produces poorly formatted log text like: missing final newline node=remote watching=true[Pipeline] } which would confuse, for example, pipeline-cloudwatch-logs.
… compatible with this plugin.
…oids the need for a workaround.
src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java
Show resolved
Hide resolved
@@ -599,6 +652,7 @@ private void handleExit(int exitCode, OutputSupplier output) throws IOException, | |||
getContext().onFailure(new AbortException("script returned exit code " + exitCode)); | |||
} | |||
} | |||
listener().getLogger().close(); |
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.
So this call will always be on NewlineSafeTaskListener
, right? Is this why we don't want to call super.close()
in NewlineSafeTaskListener.$NewlineSafeTaskListener.close()
? Ditto for the call below in exited
. Also, if we are calling close
here now, why didn't we call flush
here earlier? Should we have been doing 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.
So this call will always be on
NewlineSafeTaskListener
, right?
Right.
Is this why we don't want to call
super.close()
inNewlineSafeTaskListener.$NewlineSafeTaskListener.close()
?
Yes.
if we are calling
close
here now, why didn't we callflush
here earlier?
There is no particular need to flush until the end of the step (and close
flushes).
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.
There is no particular need to flush until the end of the step (and close flushes).
My question was unclear, but my confusion is about why we weren't calling flush
before this PR, since it looks like this is the end of the step.
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.
Oh, I see! We were calling flush
before, in watch mode, in exited
. In non-watch mode, it did not really matter since the log messages were coming from the master, and DefaultStepContext.getListener
always close
s the per-step listener when the step finishes.
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 fine. I am struggling to keep track of when to flush or not, what overrides of close
also close their delegates, and what is getting remoted or not in Pipeline logging in general, so my approval is mostly just based on passing tests and no Java-level issues that I see.
@@ -599,6 +652,7 @@ private void handleExit(int exitCode, OutputSupplier output) throws IOException, | |||
getContext().onFailure(new AbortException("script returned exit code " + exitCode)); | |||
} | |||
} | |||
listener().getLogger().close(); |
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.
There is no particular need to flush until the end of the step (and close flushes).
My question was unclear, but my confusion is about why we weren't calling flush
before this PR, since it looks like this is the end of the step.
So am I! |
@@ -65,6 +65,7 @@ | |||
<revision>2.33</revision> | |||
<changelist>-SNAPSHOT</changelist> | |||
<jenkins.version>2.176.1</jenkins.version> | |||
<jenkins-test-harness.version>2.54</jenkins-test-harness.version> <!-- TODO pending plugin-pom update --> |
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.
…that fix is only available on 2.176.x+
Fixing the test from #103, strengthening it in the process. Taking on some urgency since after @Vlatombe’s jenkinsci/kubernetes-plugin#552, this problem would affect any
sh
step in a Kubernetes agent which prints output without a trailing newline (no longer limited to that minority of builds which deliberately use secrets).kubernetes
test workarounds can be removed: Demonstrating that an upstream fix avoids the need for a workaround kubernetes-plugin#554pipeline-cloudwatch-logs
: Test of output lines missing final newline pipeline-cloudwatch-logs-plugin#58