Currently we're using Jenkins shared libraries which we're planning to use with custom Jenkinsfiles. Idea here is that developers should be able to manage those custom Jenkinsfiles without any additional help from DevOps team.

In order to implement this feature I need some way how to validate this custom Jenkinsfile.

Even if I have running Jenkins instance with configured shared libraries post to /pipeline-model-converter/validate wont lint my Jenkinsfile correctly as it wont load my custom libraries.

Is there a convenient way how to check custom Jenkinsfile before actually executing it on running Jenkins instance? e.g., checking if method names in Jenkinsfile are correctly written.

1 Answer 1


As far as I see, there are two possible approaches, either by misusing reusing the Blue Ocean plugin or using the Groovy-based Jenkinsfile unit test tool.

The groovy approach might be a bit of overhead, since it is not a client-side Javascript verification. An idea would be to run an async task, server side that tests the code the developer provides and returns the results to the client. You mentioned that the shared libraries are not being parsed properly. This might be resolvable through the use of mock Jenkins commands and objects. This might also avoid the security risk which is created through shared libraries, which requires users having push rights.

The client-side solution might be to provide a playground via the Blue Ocean plugin or directly present the Jenkinsfile that has been created via a redirect of the Jenkinsfile to Blue Ocean.

All in all, there is no straight forward JS library solution to your problem, as far as I can tell.

  • After some tinkering with Jenkins I have decided to use JenkinsRule instance inside of a test case and also use LibraryRetriever to load required custom libraries. This approach allows me to do some assertions in build logs as well as verify build statuses. However problem is external dependencies - git repos and slack notifications. So currently I'm still trying to come up with more lightweight solution. Will post updates afterwards.
    – zrks
    Commented Feb 6, 2018 at 15:15
  • Cool, you could also post your own answer and then accept it
    – Moritz
    Commented Feb 6, 2018 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.