0
0
Jenkinsdevops~10 mins

Jenkinsfile concept - 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 block.

Jenkins
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                [1] 'echo Building...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Ash
Bexecute
Crun
Dcommand
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' instead of 'sh' causes errors.
2fill in blank
medium

Complete the code to specify the agent as a Docker container.

Jenkins
pipeline {
    agent {
        docker {
            image '[1]'
        }
    }
    stages {
        stage('Test') {
            steps {
                sh 'echo Testing...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aubuntu:latest
Bnodejs:12
Cpython:3.8
Dmysql:5.7
Attempts:
3 left
💡 Hint
Common Mistakes
Using an unrelated image like 'mysql:5.7' for a build agent.
3fill in blank
hard

Fix the error in the stage declaration by completing the missing keyword.

Jenkins
pipeline {
    agent any
    stages {
        [1]('Deploy') {
            steps {
                sh 'echo Deploying...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Astep
Btask
Cstage
Djob
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'step' or 'job' instead of 'stage' causes syntax errors.
4fill in blank
hard

Fill both blanks to create a post-build action that always runs a cleanup step.

Jenkins
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'echo Building...'
            }
        }
    }
    post {
        [1] {
            [2] {
                sh 'echo Cleaning up...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aalways
Bsuccess
Csteps
Dfailure
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'success' instead of 'always' will skip cleanup on failure.
5fill in blank
hard

Fill all three blanks to define an environment variable and use it in a shell step.

Jenkins
pipeline {
    agent any
    environment {
        [1] = '[2]'
    }
    stages {
        stage('Print') {
            steps {
                sh 'echo [3]'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AMY_VAR
BHelloWorld
C$MY_VAR
DGREETING
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable name and reference inconsistently causes empty output.