0
0
Jenkinsdevops~10 mins

@Library annotation 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 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'
Autils
Bcommon
CsharedLib
Dlibrary
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.
2fill in blank
medium

Complete 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'
Atools
Bcommon
Cutils
Dlibs
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets for multiple libraries.
Missing quotes around library names.
3fill in blank
hard

Fix 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'
Atools:1.0
Btools@1.0
Ctools-1.0
Dtools
Attempts:
3 left
💡 Hint
Common Mistakes
Including the version in the blank causing '@1.0' to appear twice.
Using wrong separators like '-' or ':'.
4fill in blank
hard

Fill 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'
Acommon
B2.1
C1.0
Dutils
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping version and name in blanks.
Using wrong version numbers.
5fill in blank
hard

Fill 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'
Aalpha
B3.0
CgammaLib
Ddelta
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing library names and versions in wrong blanks.
Using wrong library names not matching the code.