0
0
Jenkinsdevops~10 mins

Testing shared libraries in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a shared library in Jenkins pipeline.

Jenkins
def lib = [1] 'my-shared-library'
Drag options to blanks, or click blank then click option'
AloadLibrary
BuseLibrary
Clibrary
DimportLibrary
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'loadLibrary' instead of 'library'
Trying to import shared libraries like regular code
2fill in blank
medium

Complete the code to call a function named 'buildApp' from the shared library.

Jenkins
lib.[1]()
Drag options to blanks, or click blank then click option'
ArunBuild
BbuildApp
CstartBuild
DexecuteBuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names that do not exist in the library
Forgetting to call the function with parentheses
3fill in blank
hard

Fix the error in the pipeline code to correctly load the shared library with a specific version.

Jenkins
def lib = library('[1]@v1.2.3')
Drag options to blanks, or click blank then click option'
Amy-shared-library
Bmy_shared_library
Cmy-shared-library/v1.2.3
Dmy-shared-library:v1.2.3
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores instead of dashes in the library name
Using slashes or colons instead of '@' to specify version
4fill in blank
hard

Fill both blanks to define a test pipeline that loads the shared library and calls 'testApp' function.

Jenkins
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        script {
          def lib = [1] 'my-shared-library'
          lib.[2]()
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alibrary
BbuildApp
CtestApp
DloadLibrary
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'loadLibrary' instead of 'library'
Calling 'buildApp' instead of 'testApp' for testing
5fill in blank
hard

Fill all three blanks to create a Jenkinsfile that loads a shared library, calls 'deployApp', and uses a specific version 'v2.0'.

Jenkins
pipeline {
  agent any
  stages {
    stage('Deploy') {
      steps {
        script {
          def lib = [1] '[2]@[3]'
          lib.deployApp()
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Alibrary
Bmy-shared-library
Cv2.0
DdeployApp
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the version in the wrong place
Using incorrect syntax for loading the library with version