0
0
Jenkinsdevops~10 mins

Implicit vs explicit loading in Jenkins - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Implicit vs explicit loading
Start Jenkins Pipeline
Load Jenkinsfile
Implicit Loading
Jenkins auto-loads shared libraries
Pipeline runs with auto-loaded code
Explicit Loading
Pipeline calls load() or @Library
Shared libraries loaded manually
Pipeline runs with explicitly loaded code
Jenkins pipelines can load shared libraries either automatically (implicit) or by manual commands (explicit). This flow shows how Jenkins handles each loading method.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Example') {
      steps {
        script {
          def lib = load 'vars/myLib.groovy'
          lib.sayHello()
        }
      }
    }
  }
}
This pipeline explicitly loads a Groovy script from the repository and calls a function from it.
Process Table
StepActionLoading TypeEvaluationResult
1Start pipeline executionN/AN/APipeline begins
2Jenkins reads JenkinsfileN/AN/APipeline script loaded
3Check for implicit librariesImplicitAre shared libraries configured for auto-loading?If yes, libraries auto-loaded
4Execute pipeline stepsExplicitEncounter load 'vars/myLib.groovy'Script loaded explicitly into variable 'lib'
5Call lib.sayHello()ExplicitInvoke function from loaded scriptFunction runs, output produced
6Pipeline completesN/AN/APipeline ends successfully
💡 Pipeline ends after all steps complete
Status Tracker
VariableStartAfter Step 4After Step 5Final
libnullGroovy script object loadedFunction sayHello executedGroovy script object remains
Key Moments - 3 Insights
Why does Jenkins sometimes load shared libraries automatically without explicit commands?
Because Jenkins can be configured to auto-load shared libraries implicitly before pipeline execution, as shown in step 3 of the execution table.
What happens when the pipeline uses the load() command explicitly?
The pipeline manually loads the specified Groovy script at runtime, assigning it to a variable, as shown in step 4 and tracked in variable 'lib'.
Can explicit loading replace implicit loading?
Yes, explicit loading gives you control to load scripts only when needed, unlike implicit loading which happens automatically before pipeline runs.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does Jenkins explicitly load the Groovy script?
AStep 3
BStep 4
CStep 5
DStep 2
💡 Hint
Check the 'Action' and 'Loading Type' columns in step 4 for explicit loading
According to the variable tracker, what is the state of variable 'lib' after step 5?
Anull
BGroovy script object loaded
CFunction sayHello executed
DPipeline completed
💡 Hint
Look at the 'After Step 5' column for variable 'lib' in the variable tracker
If Jenkins is configured to not auto-load shared libraries, which step in the execution table would be skipped?
AStep 3
BStep 4
CStep 5
DStep 6
💡 Hint
Step 3 describes implicit loading; if disabled, it won't happen
Concept Snapshot
Implicit loading: Jenkins auto-loads shared libraries before pipeline runs.
Explicit loading: Pipeline uses load() or @Library to load scripts manually.
Implicit is automatic, explicit is manual and controlled.
Use explicit loading to load scripts only when needed.
Both methods provide shared code reuse in Jenkins pipelines.
Full Transcript
This visual execution shows how Jenkins pipelines load shared libraries implicitly and explicitly. The pipeline starts and Jenkins reads the Jenkinsfile. If configured, Jenkins auto-loads shared libraries implicitly before running steps. Alternatively, the pipeline can explicitly load scripts using the load() command, assigning the loaded script to a variable. The variable can then call functions from the loaded script. The execution table tracks each step, showing when implicit or explicit loading happens. The variable tracker shows the state of the loaded script variable across steps. Key moments clarify why Jenkins auto-loads libraries and how explicit loading works. The quiz tests understanding of when loading occurs and variable states. This helps beginners see the difference between implicit and explicit loading in Jenkins pipelines.