I could reproduce this with a simple Jenkinsfile that just contains "echo 'Hello-World!'".
See attached file Jenkinsfile
.
Steps to reproduce
- Add the attached Jenkinsfile to a GIT repo.
- Create a Pipeline Job.
- Set Definition to "Pipeline script from SCM".
- Set "SCM "to "Git", configure the repository and point "Script Path" to the Jenkinsfile.
If the file has a UTF-8-BOM, the Job fails with
java.lang.NoSuchMethodError: No such DSL method 'echo' found among steps [archive, bat, ... zip] or globals [currentBuild, docker, env, params, pipeline, scm]
Remove the BOM, check in, push and the job will run as expected.
Tested with Jenkins ver. 2.176.1
Hier is a Stacktrace wenn the Groovy file contains a BOM and begins with the groovy file marker (#!groovy)
It seams the the whole file will be parsed without the BOM has been removed before.