Jenkins "Loading libraries failed" - Fix Shared Library Load Errors
Jenkins resolved your shared library but could not load it - the Groovy in vars/ or src/ failed to compile, or a class it references is missing. The pipeline never starts because the library is loaded before any stage runs.
What this error means
The build fails at the very top with Loading libraries failed followed by a Groovy compilation error pointing at a file inside the library (vars/foo.groovy or src/com/...). The Jenkinsfile itself is fine; the failure is in the library code it pulled in.
Loading libraries failed
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/vars/deployApp.groovy: 12: unable to resolve class com.example.Deployer
@ line 12, column 5.
1 errorCommon causes
Groovy compile error in the library
A syntax error, an unresolved class, or a bad import inside vars/ or src/ makes the whole library fail to compile, and Jenkins loads the entire library up front.
A referenced class is missing from src/
A var references a helper class under src/ that was never added, was renamed, or sits in the wrong package path, so the loader cannot resolve it.
How to fix it
Fix the Groovy that fails to compile
- Read the file and line in the error - it points inside the library, not the Jenkinsfile.
- Resolve missing classes by placing them under
src/<package>/<Name>.groovywith a matching package declaration. - Validate the library with its own unit tests (e.g. the Jenkins Pipeline Unit framework) before publishing the version.
Pin the library to a known-good version
Reference a tag that compiles cleanly rather than a moving branch that may carry a broken commit.
@Library('platform-lib@v2.3.0') _
pipeline { agent any; stages { stage('CI') { steps { ciBuild() } } } }How to prevent it
- Unit-test shared libraries in their own repo before tagging a release.
- Pin pipelines to library tags, not moving branches, for release builds.
- Keep
src/package paths aligned with the class package declarations.