[JENKINS-38381] API to receive asynchronous notifications#29
[JENKINS-38381] API to receive asynchronous notifications#29jglick wants to merge 25 commits intojenkinsci:masterfrom
Conversation
…f process output or exit code.
…ller call ProcessLiveness. It is guaranteed to not find the process, which would cause an immediate -1 return value. Instead limit the watcher to the simple result file, and check for special statuses only if exitStatus is being called from the master.
| } | ||
| CountingInputStream cis = new CountingInputStream(utf8EncodedStream); | ||
| handler.output(cis); | ||
| lastLocationFile.write(Long.toString(lastLocation + cis.getByteCount()), null); |
There was a problem hiding this comment.
Seems that this would not suffer from JENKINS-37575-like problems. We intentionally write lastLocationFile only after a successful call to output, so that if there is an agent channel outage we do not lose output. In such a case this Watcher simply dies; if and when the agent is reconnected, a new one should start at the same position.
| try (FileChannel ch = FileChannel.open(Paths.get(logFile.getRemote()), StandardOpenOption.READ)) { | ||
| InputStream locallyEncodedStream = Channels.newInputStream(ch.position(lastLocation)); | ||
| InputStream utf8EncodedStream; | ||
| Charset nativeEncoding = Charset.defaultCharset(); |
There was a problem hiding this comment.
I assume this is taking the agent's default character set. If so ...
For various reasons (e.g. JENKINS-13091) we might be in a situation that the agent does not run with the systems default encoding, i.e. the –Dfile.encoding=… jvm parameter changing it to something else. Therefore system default encoding might be a good default. However, it should be possible to set the encoding explicitly since encoding of any shell output (IBM1047 on z/OS) does not necessarily match the encoding set by –Dfile.encoding.
|
Now identical to #62, which better captures the relationship among changes. |
Related to jenkinsci/workflow-job-plugin#27.
@reviewbybees esp. @oleg-nenashev