-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shell/octo): adds workaround for dotnet runtime issue with additi…
…onal logging
- Loading branch information
Marcel Kesselring
authored and
Marcel Kesselring
committed
May 27, 2021
1 parent
5e5a2cd
commit 8bab6b1
Showing
8 changed files
with
34 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
package com.liftric.octopusdeploy | ||
|
||
import org.slf4j.Logger | ||
import java.io.File | ||
|
||
internal fun shell(cmd: String): ShellResult = File(".").shell(cmd) | ||
internal fun shell(cmd: String, logger: Logger): ShellResult = File(".").shell(cmd, logger) | ||
|
||
internal fun File.shell(cmd: String): ShellResult { | ||
val process = Runtime.getRuntime().exec(arrayOf("sh", "-c", cmd), emptyArray(), this) | ||
internal fun File.shell(cmd: String, logger: Logger): ShellResult { | ||
val tmpDir = System.getProperty("java.io.tmpdir") | ||
// DOTNET_BUNDLE_EXTRACT_BASE_DIR is a workaround for https://github.com/dotnet/runtime/issues/3846 | ||
val cmdarray = arrayOf("sh", "-c", "DOTNET_BUNDLE_EXTRACT_BASE_DIR=$tmpDir $cmd") | ||
val cmdDir = this | ||
logger.debug("shell: cmdarray='${cmdarray.toList()}'") | ||
logger.debug("shell: cmdDir='$cmdDir'") | ||
logger.debug("shell: tmpDir='$tmpDir'") | ||
val process = Runtime.getRuntime().exec(cmdarray, emptyArray(), cmdDir) | ||
val exitCode = process.waitFor() | ||
val inputText = process.inputStream.bufferedReader().readText().trim() | ||
val errorText = process.errorStream.bufferedReader().readText().trim() | ||
return ShellResult(exitCode, inputText, errorText) | ||
val result = ShellResult(exitCode, inputText, errorText) | ||
logger.debug("shell: result=$result") | ||
return result | ||
} | ||
|
||
data class ShellResult(val exitCode: Int, val inputText: String, val errorText: String) | ||
data class ShellResult(val exitCode: Int, val inputText: String, val errorText: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters