Here is the folder structure in my shared library repo:

$ tree src vars
├── org
    └── common.groovy

├── testSrc.groovy

src has:

$ cat src/org/common.groovy
package org.common

class CommonFuncs {
    def sayHi() {
        echo "Hi from CommonFuncs!"

    def sayHello(str) {
        echo "Hello ${str}"

and vars:

$ cat vars/testSrc.groovy
def call() {
    def tst = new org.common.CommonFuncs()
    return tst.sayHi()

pipeline script in Jenkins has:

@Library('jenkins-library') _
pipeline {
    agent { label 'my_servers' }

    stages {
        stage('test') {
            steps {

When I run job, I get below error:

org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
/var/jenkins_home/jobs/Test/jobs/mave/jobs/test_src/builds/8/libs/jenkins-library/vars/testSrc.groovy: 2: unable to resolve class org.common.CommonFuncs 
 @ line 2, column 15.
       def tst = new org.common.CommonFuncs()

What is wrong in here? I am new to groovy, and this is my first attempt to create a class in shared library src/, any help is appreciated.

  • is it possible to have the class in src/ and use it in vars/?
    – rodee
    Commented May 13, 2020 at 13:42
  • Try renaming common.groovy in CommonFuncs.groovy and moving it to src/org/common/. Commented May 13, 2020 at 16:36
  • That worked, renamed the groovy file to match class name. thank you.
    – rodee
    Commented May 13, 2020 at 17:06
  • @GuidoVaccarella, can you add it as answer?
    – rodee
    Commented May 13, 2020 at 18:48

1 Answer 1


It looks like Groovy can't find your class at the path specified.

Try renaming the file common.groovy to match the class name and move it to the common folder:

  • I was creating a filename with lowercase style, but remembering what u mentioned, helped me a lot, specially the words highlighted in the jenkins documentation : The basename of each .groovy file should be a Groovy (~ Java) identifier, conventionally camelCased. , reference : jenkins.io/doc/book/pipeline/shared-libraries/… Commented Feb 20, 2023 at 3:10

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.