How to use 'sh returnStatus' with a multi-line shell script?

Hi

In declarative pipeline, I want to capture the return code from my application. I understand I can do this using sh returnStatus, for example:

results[nextFile] = sh returnStatus: true, script: "./myApp $nextFile"

but I also need to prefix the application call with a few other shell commands:

sh """
    umask 007
    export TARGET_ROOT=$target_path
    ./myApp $nextFile
"""

How can I use returnStatus to get the return code of the last command (./myApp) in this case please?

Fixed, I can just use:

results[nextFile] = sh returnStatus: true, script: """
    umask 007
    export TARGET_ROOT=$target_path
    ./myApp $nextFile
"""