java.lang.NoSuchMethodError: No such DSL method 'pipeline' found among steps

2,239 views
Skip to first unread message

Pablo Gandulfo

unread,
Aug 21, 2018, 4:33:38 PM8/21/18
to Jenkins Users
I got this error and invested a considerable amount of time to solve it, searching on internet and trying different approaches, all of them with no success. Finally, I found the cause and solve it. So, I would like to share this knowledge and I hope that someone at Jenkins Developer Team document this to avoid others facing the same problem.

The cause was that the Jenkinsfile was formatted with UTF-8. That's it! Firstly I was using it in ANSI, but some latin characters were appearing wrongly in the log. So I changed to UTF-8 and, suddenly, every first work I used in the script file (pipeline, node, def, etc.) didn't work anymore, throwing the same error: "java.lang.NoSuchMethodError: No such DSL method 'XXXXX' found among steps".

I imagine that this may be the cause of JENKINS-52844 , which was opened recently. So, Andrew Bayer (@abayer), I hope you see this message too.

Regards,
Pablo.

Mark Waite

unread,
Aug 21, 2018, 7:15:14 PM8/21/18
to jenkins...@googlegroups.com
Can you explain further what you mean when you say that the file was formatted with UTF-8?

As an example, I have a scripted Pipeline Jenkinsfile which includes Japanese characters and is well-behaved.  I am reasonably certain that it is UTF-8.  I have a declarative Jenkinsfile which also includes Japanese characters and is well-behaved.

Does the file you are editing use a byte-order mark to indicate that it is UTF-8?

Is there some other technique that indicates it is a UTF-8 file?

If you can provide steps to duplicate the problem, feel free to upload those steps to JENKINS-52844, or to create a new bug report if you believe that the bug you're seeing does not match JENKINS-52844.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0d435cdd-0669-4ed5-9142-bb58730bece6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pablo Gandulfo

unread,
Aug 22, 2018, 2:46:04 PM8/22/18
to Jenkins Users
Hi Mr. Mark Waite,

Maybe there is another issue related to this problem, related to countries using latin encoding as standard (I'm from Brazil).

I didn't use any special byte-order mark. These are the steps needed to reproduce the error:

1) Choose a very simple jenkinsfile:

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                echo 'Building..'
            }
        }
        stage('Test') {
            steps {
                echo 'Testing..'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying....'
            }
        }
    }
}

2) Create it with Notepad++, choose UTF-8 encoding, save it and commit/push to a Git branch;

3) From a Pipeline Job at Jenkins, configure it to retrieve that branch and run the jenkinsfile;

4) Launch the job. It will complain about "java.lang.NoSuchMethodError: No such DSL method 'pipeline' found among steps".
Note: whatever command you choose in the jenkinsfile as the first one (node, stage, etc.), all of them will throw the same error;

5) At Notepad++, now change to ANSI encoding, save it and commit/push to Git;

6) Launch the same job. It will run with success.

Regards,
Pablo.

Jan Monterrubio

unread,
Aug 22, 2018, 8:19:01 PM8/22/18
to jenkins...@googlegroups.com
Do you have the jobdsl plugin installed? 

Björn Pedersen

unread,
Aug 23, 2018, 12:49:27 AM8/23/18
to Jenkins Users
Hi,



2) Create it with Notepad++, choose UTF-8 encoding, save it and commit/push to a Git branch;


And I guess that is where  the byte-order mark slips in (thats something that happens mostly on Windows systems, and it's invisible in the file).
Check https://notepad-plus-plus.org/community/topic/14355/encoding-without-bom-where to see how to write a file without BOM mark at the beginning.

Björn

Pablo Gandulfo

unread,
Aug 23, 2018, 7:48:33 AM8/23/18
to Jenkins Users
No, I don't.

Pablo Gandulfo

unread,
Aug 23, 2018, 8:11:32 AM8/23/18
to Jenkins Users
Hi Mr. Björn,

Humm didn't know that Notepad++ was adding the BOM mark. Great to know that. I just tested now, without the BOM mark, and everything works ok.

So, maybe, Jenkins should give a more reasonable error message in these cases? I mean, if the problem is the BOM mark, why complain about bad script sintax? I searched for some time in internet, and found no reference about this cause.

Regards,
Pablo.
Reply all
Reply to author
Forward
0 new messages