0
0
Jenkinsdevops~10 mins

System configuration management 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 pipeline phase, like 'Test' instead of 'Build'.
2fill in blank
medium

Complete the code to specify the agent as a Docker container with the image 'python:3.8'.

Jenkins
pipeline {
    agent {
        docker {
            image '[1]'
        }
    }
    stages {
        stage('Run') {
            steps {
                echo 'Running inside Docker'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aalpine:3.12
Bubuntu:20.04
Cnode:latest
Dpython:3.8
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic image like 'node:latest' when Python is needed.
3fill in blank
hard

Fix the error in the Jenkinsfile snippet by completing the missing keyword to run shell commands.

Jenkins
pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                [1] 'echo Testing the build'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Ascript
Bsh
Cbat
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'script' or 'run' which are not valid steps for shell commands.
4fill in blank
hard

Fill both blanks to create a Jenkins pipeline that triggers only when the branch is 'main' and the build result is successful.

Jenkins
pipeline {
    agent any
    triggers {
        pollSCM('[1]')
    }
    stages {
    }
    post {
        [2] {
            echo 'Build succeeded on main branch'
        }
    }
}
Drag options to blanks, or click blank then click option'
AH/5 * * * *
Balways
Csuccess
Dfailure
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'always' in post which runs regardless of build result.
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline environment variable, use it in a stage, and echo its value.

Jenkins
pipeline {
    agent any
    environment {
        GREETING = '[1]'
    }
    stages {
        stage('Say Hello') {
            steps {
                echo '[2]'
                echo "$[3]"
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AHello, Jenkins!
BGREETING
DHi there!
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes for variable expansion which does not work in Jenkins pipeline.