Skip to content
Advertisement

Fail the build/script as per os.system()’s output

I’m trying to create helm charts and push them to Nexus repository in parallel(multiprocessing) on 100s of folders and its working good.

But, I would like to fail the script or the build, incase the exit status is other than 0. With my current code set up, even though the exit code returns non zero value, here 512, the build ends up as success.

Expectation: even if a single process fails, fail the build..

folder structure:

JavaScript

code:

JavaScript

Output:

JavaScript

ps -ef |grep python

JavaScript

Edit: Tried an alternate option to capture the result of executor.submit , but after the failure of the 1st process, it exits the script, instead of waiting for all the threads or process to complete and then fail the build.

JavaScript

alternate approach

JavaScript

Advertisement

Answer

You should check the result of executor.submit and in case of an error stop the executor.

Advertisement