| Trouble using shared pipeline libraries | Ramanathan Muthaiah | 12/22/16 1:28 AM | Am running Jenkins v2.3x with Pipeline plugin running at v2.x In the repo root, I have a Jenkinsfile from which shared library is meant to be used. repo_root / |_____ Jenkinsfile | |_____ vars / | |____ buildUtils.groovy Within the buildUtils.groovy, this is the code snippet: With this setup in place, running Jenkins build job for this repo, fails with this error: [Pipeline] End of Pipeline java.lang.NoSuchMethodError: No such DSL method 'buildUtils' found among steps |
| Re: Trouble using shared pipeline libraries | Torsten Reinhard | 12/25/16 2:32 AM | can you provide some more info, especially * how does your Jenkisfile look like * do you have global shared library configured or per folder? * which version of the shared library do you adress? Is your script available in that version? * do you have same script in the internal repo? Regards, Torsten |
| Re: Trouble using shared pipeline libraries | Ramanathan Muthaiah | 12/25/16 5:33 AM | Here are some details but am not confident about my setup based on what you're asking. Maybe, you can help me to clarify what am doing incorrectly.
[Ram] : Jenkinsfile content is: buildUtils("git")
[Ram] : Looks like am missing some configuration here but fail to understand what is it from the plugin docs ?
[Ram] : Am not sure if understood your question. Shared Groovy library plugin installed is v2.5
[Ram] : Jenkinsfile and vars/buildUtils.groovy are in the same repo TIA, /Ram |
| Re: Trouble using shared pipeline libraries | Torsten Reinhard | 12/26/16 9:18 AM | Hi try to separate your Jenkinsfile from the code of your shared library. Usually the shared library provides some global functions that you may re-use in some Jenkinsfile(s) => the library is shared code, the Jenkinsfile belongs to your project(s) using that library. Than, make sure you know what version of the library you are using: - configure it in Jenkins/manage Jenkins -> global shared library. Here you´ll have to setup repo, branch, credentials to your shared library. You can also configure it on a per folder base and you may reference it using the annotation@Library('somelib') It´s pretty well documented at https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/README.md Good luck! Best regards, Torsten |
| Re: Trouble using shared pipeline libraries | Ramanathan Muthaiah | 12/30/16 1:11 AM | Hi Torsten,
[Ram] : I did start writing the library with this separation ; after re-reading the documentation, moved this library has been moved to it's own repo.
[Ram] : Updated this configuration too. With these changes, global shared libs are now usable from the Jenkinsfile. /Ram |