Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a shared library named 'utils' in a Jenkinsfile.
Jenkins
library('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name instead of the library name.
Forgetting to put the library name in quotes.
✗ Incorrect
The 'library' step loads the shared library by its name, here 'utils'.
2fill in blank
mediumComplete the code to load a library with the identifier 'myLib' and specify the version '1.2.3'.
Jenkins
library(identifier: '[1]@1.2.3')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the version as a separate parameter.
Omitting the '@' symbol before the version.
✗ Incorrect
The 'identifier' parameter specifies the library name and version using '@'.
3fill in blank
hardFix the error in the code to correctly load a library named 'tools' with default version.
Jenkins
library('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including '@' without a version causes syntax errors.
Adding invalid version strings like '@default'.
✗ Incorrect
To load the default version, omit the '@' symbol and version. Just use the library name.
4fill in blank
hardFill both blanks to load a library named 'commonLib' with version '2.0' and assign it to a variable 'lib'.
Jenkins
def lib = library('[1]@[2]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping version numbers.
Using wrong library names.
✗ Incorrect
The library name is 'commonLib' and the version is '2.0'. Assigning to 'lib' stores the library object.
5fill in blank
hardFill all three blanks to load a library named 'buildTools' with version '3.1.4', assign it to 'tools', and call its 'compile' method.
Jenkins
def tools = library('[1]@[2]') tools.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names.
Omitting the parentheses when calling the method.
✗ Incorrect
Load 'buildTools' version '3.1.4', assign to 'tools', then call 'compile()' method.