0
0
Jenkinsdevops~10 mins

Node and stage blocks 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 define a Jenkins pipeline stage named 'Build'.

Jenkins
stage('[1]') {
    steps {
        echo 'Building the project'
    }
}
Drag options to blanks, or click blank then click option'
ATest
BDeploy
CBuild
DClean
Attempts:
3 left
💡 Hint
Common Mistakes
Using a stage name that does not match the intended phase.
Forgetting to put the stage name in quotes.
2fill in blank
medium

Complete the code to specify the node label 'linux' for running the pipeline.

Jenkins
node('[1]') {
    stage('Test') {
        steps {
            echo 'Running tests'
        }
    }
}
Drag options to blanks, or click blank then click option'
Adocker
Blinux
Cmac
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Using a node label that does not exist on the Jenkins server.
Forgetting to put the node label in quotes.
3fill in blank
hard

Fix the error in the node block to correctly specify the agent.

Jenkins
node [1] {
    stage('Deploy') {
        steps {
            echo 'Deploying application'
        }
    }
}
Drag options to blanks, or click blank then click option'
A'docker'
Bdocker
C'docker-agent'
Ddocker-agent
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the node label.
Using an incorrect label name.
4fill in blank
hard

Fill both blanks to create a stage named 'Test' that runs on a node labeled 'windows'.

Jenkins
node([1]) {
    stage([2]) {
        steps {
            echo 'Running tests'
        }
    }
}
Drag options to blanks, or click blank then click option'
A'windows'
B'Test'
C'test'
D'linux'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the node label or stage name.
Using incorrect case for the stage name.
5fill in blank
hard

Fill all three blanks to create a pipeline that runs on a 'linux' node, has a stage named 'Build', and echoes 'Building project'.

Jenkins
node([1]) {
    stage([2]) {
        steps {
            echo [3]
        }
    }
}
Drag options to blanks, or click blank then click option'
A'linux'
B'Build'
C'Building project'
D'Deploy'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around strings.
Using wrong stage name or echo message.