What does `sh` vs `bat` vs `powershell` do, and what are common `sh` options?

BeginnerConceptJenkins
Answer

sh runs a shell script on Unix agents, bat on Windows cmd, and powershell/pwsh for PowerShell. sh defaults to -xe, so commands are echoed and the script stops at the first failing command. Useful options are returnStdout: true to capture output, returnStatus: true to get the exit code without failing the build, and label to name the step in the UI.

def sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
All CI/CD questions

More on Jenkins