0
0
Jenkinsdevops~10 mins

Creating reusable pipeline steps in Jenkins - Interactive Practice

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

Complete the code to define a reusable pipeline step named 'buildApp'.

Jenkins
def [1]() {
    echo 'Building the application'
}
Drag options to blanks, or click blank then click option'
AstartBuild
BrunBuild
CbuildApp
DbuildStep
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic or unclear function name.
Forgetting to define the function before calling it.
2fill in blank
medium

Complete the code to call the reusable step 'buildApp' inside the pipeline.

Jenkins
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                [1]()
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
ArunBuild
BbuildStep
CstartBuild
DbuildApp
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function name that was not defined.
Omitting parentheses when calling the function.
3fill in blank
hard

Fix the error in the reusable step definition by completing the missing keyword.

Jenkins
[1] buildApp() {
    echo 'Building the application'
}
Drag options to blanks, or click blank then click option'
Adef
Bstep
Cfunction
Dpipeline
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'function' which is not valid Groovy syntax.
Omitting the keyword entirely.
4fill in blank
hard

Fill both blanks to define and call a reusable step named 'testApp' that prints 'Testing application'.

Jenkins
def [1]() {
    echo '[2]'
}
pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                testApp()
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AtestApp
BTesting application
CBuild application
DrunTest
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between function name and call.
Incorrect or unrelated echo message.
5fill in blank
hard

Fill all three blanks to create a reusable step 'deployApp' that takes an environment parameter and prints a deployment message.

Jenkins
def [1](env) {
    echo "Deploying to [2] environment"
}
pipeline {
    agent any
    stages {
        stage('Deploy') {
            steps {
                [3]('production')
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AdeployApp
Benv
Ddeploy
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the function in definition and call.
Not using the parameter inside the echo message.