By default, shell can break Jenkins pipeline if exit code different from 0. But ideally need to create handler for catch error and provide actions based on error code from script.
For catch error code for shell script need to call sh with argument returnStatus: true
def script = "ls -lh"
def statusCode = sh(returnStatus: true, script: script)