Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a shared library named 'utils' in a Jenkins pipeline.
Jenkins
@Library('[1]') _ pipeline { agent any stages { stage('Example') { steps { echo 'Using shared library' } } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong library name that is not configured in Jenkins.
Forgetting to add the underscore (_) after the annotation.
✗ Incorrect
The @Library annotation requires the exact name of the shared library to load, here 'utils'.
2fill in blank
mediumComplete the code to load multiple shared libraries 'utils' and 'helpers' in a Jenkins pipeline.
Jenkins
@Library(['[1]', 'helpers']) _ pipeline { agent any stages { stage('Test') { steps { echo 'Multiple libraries loaded' } } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets for multiple libraries.
Missing quotes around library names.
✗ Incorrect
To load multiple libraries, list their names in an array. Here, 'utils' and 'helpers' are loaded.
3fill in blank
hardFix the error in the code to properly load the 'tools' shared library with a version '1.0'.
Jenkins
@Library('[1]@1.0') _ pipeline { agent any stages { stage('Build') { steps { echo 'Library version loaded' } } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the version in the blank causing '@1.0' to appear twice.
Using wrong separators like '-' or ':'.
✗ Incorrect
The version is specified after '@' in the string. The blank should only contain the library name 'tools'.
4fill in blank
hardFill both blanks to load the 'common' library with version '2.1' and alias it as 'cmn'.
Jenkins
@Library('[1]@[2]') cmn pipeline { agent any stages { stage('Deploy') { steps { script { cmn.deployApp() } } } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping version and name in blanks.
Using wrong version numbers.
✗ Incorrect
The library name is 'common' and the version is '2.1' to match the alias usage.
5fill in blank
hardFill all three blanks to load libraries 'alpha', 'beta' version '3.0', and 'gammaLib'.
Jenkins
@Library(['[1]', 'beta@[2]', '[3]@1.5']) _ pipeline { agent any stages { stage('Integration') { steps { script { alpha.run() beta.test() gammaLib.deploy() } } } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing library names and versions in wrong blanks.
Using wrong library names not matching the code.
✗ Incorrect
The libraries are 'alpha', 'beta' with version '3.0', and 'gammaLib' with version '1.5'.