`hudson.AbortException: script returned exit code 127`
BeginnerTroubleshootingJenkinsfile syntax, Groovy & CPS errors
Answer
Likely causes → Command not found in the container or agent where sh ran: running in jnlp instead of the tool container, wrong image, missing PATH.
Diagnose →
sh 'echo $PATH; which node || true; cat /etc/os-release'
Check whether the step is inside container('node') or a defaultContainer is set.
Fix → Wrap with container('node') { }, set defaultContainer, or use an image that has the tool.
Prevent → Standard pod templates per stack in the shared library.
More on Jenkinsfile syntax, Groovy & CPS errors
`WorkflowScript: 1: Missing required section "agent" @ line 1, column 1.`Beginner`Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.`Beginner`java.lang.NoSuchMethodError: No such DSL method 'withSonarQubeEnv' found among steps [archive, bat, build, ...]`Beginner`java.io.NotSerializableException: java.util.regex.Matcher`Advanced`java.io.NotSerializableException: groovy.json.internal.LazyMap`Intermediate`org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object`Intermediate