-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Bash scripts seem to flakily fail #304
Comments
@alacoste Thanks for opening this issue. In order to run jenkins-std-lib/src/org/dsty/system/os/shell/Bash.groovy Lines 43 to 64 in c904931
So when you run a command, it creates 3 files I'm not sure exactly what the problem might be. It could be that the By flaky, I take it that you mean that sometimes a script fails and sometimes it doesn't. That seems to eliminate the possibility of the env.PIPELINE_LOG_LEVEL = "DEBUG"
bashResult('flaky_command')
env.PIPELINE_LOG_LEVEL = "INFO" Hopefully we can get this fixed. |
I think you are onto something about the race condition. I ended up replacing this with a custom implementation I made myself that generates a random filename for the stdout/stderr files, and I don't have the problem anymore. My working code:
Note that I now only use the code above for stuff that actually needs exitCode + stdOut, otherwise I just do:
So possibly I now avoid other possible problems with the "writing to files" workaround, and this is why it works. In any case, I think it makes sense to add randomness, so if/when you do add it lmk and I can give it a try again, with the log level DEBUG this time. |
I think it makes sense to eliminate the race condition so the code works with the pipeline parallel feature. I was thinking of using a hash of the command string way back when I wrote this code but now that I think about it, you could still run into issues with parallel code. So I think the random string is probably the best bet. You will need to know the random string inside the format script function because that is where the output file names are set. You will also need it in the read outputs function. I guess that means putting a property on the class Bash implements Shell {
String filePrefix = randomString(8) If that doesnt work you can do something like this. class Bash implements Shell {
String filePrefix
@NonCPS
String getFilePrefix {
String prefix = randomString(8)
return prefix
} Jenkins is strange like this ^ |
Sorry I forgot to paste it there, but
I have not had any CPS-related problem with this. |
If you want you can put that in the bash class or put it in something like |
Hello!
We recently started using this lib in our jenkins pipelines, and just tried to expand its usage to replace our "sh()" invocations with
org.dsty.system.os.shell.Bash
.However we are running in what seems to be random errors (flaky, but frequent enough that it often shows up on at least once in our many sh() calls in a given pipeline).
Our jenkins pipeline code looks like:
And the pipeline failure logs look like (extracted only what seem like relevant lines):
From these logs my hunch for the ~root cause is that the library somehow fails to create some script file it intends to run for the command, but completely unsure!
Here is the blue ocean view:

The text was updated successfully, but these errors were encountered: