-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add short sleep time after executing commands
I could not find out why this happens, but for example if we call `git checkout -b` immediately followed by `git rev-parse` from Gradle the output will be empty. I tried to reproduce it locally and with plain Git but couldn't. It only happens during the release job when it runs as GitHub action, so it is quite hard to debug. By my understanding the process should be finished if `waitFor()` returns (and the exit code is even 0), but somehow this does not work reliably. So for now I decided to go the quick and dirty way and simply add a short sleep time after executing shell commands. Signed-off-by: Peter Gafert <[email protected]>
- Loading branch information
1 parent
88d8fcd
commit 18bdaae
Showing
3 changed files
with
20 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ext.executeCommand = { List<String> command -> | ||
new StringBuilder().with { output -> | ||
def error = new StringBuilder() | ||
def exitCode = command.execute() | ||
.with { | ||
it.consumeProcessOutputStream(output) | ||
it.consumeProcessErrorStream(error) | ||
it | ||
}.waitFor() | ||
Thread.sleep(100) // For some reason a call right after `waitFor` might fail, so we wait a little bit :-( | ||
assert exitCode == 0: "Command '$command' failed with exit code $exitCode: $error" | ||
output.toString().trim() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
apply from: scriptRelativePath(this, 'process-utils.gradle') | ||
|
||
ext.gitCheckOut = { String url, File targetDir, String branch = null -> | ||
def branchSuffix = branch ? " --branch ${branch}" : '' | ||
targetDir.deleteDir() | ||
targetDir.mkdirs() | ||
['sh', '-c', "git clone ${url}${branchSuffix} ${targetDir.absolutePath}"].execute().waitFor() | ||
executeCommand(['sh', '-c', "git clone ${url}${branchSuffix} ${targetDir.absolutePath}"]) | ||
} |