0
0
Jenkinsdevops~10 mins

Deployment pipelines (dev, staging, prod) 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
BBuild
CDeploy
DCleanup
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong stage name like 'Test' or 'Deploy' here.
2fill in blank
medium

Complete the code to specify the agent for the pipeline to run on any available node.

Jenkins
pipeline {
    agent [1]
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Adocker
Blabel 'linux'
Cany
Dnone
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'none' disables the agent, causing errors.
3fill in blank
hard

Fix the error in the stage declaration to correctly name the 'Deploy to Staging' stage.

Jenkins
stage([1]) {
    steps {
        echo 'Deploying to staging environment'
    }
}
Drag options to blanks, or click blank then click option'
A'Deploy to Staging'
BDeploy to Staging
C"Deploy to Staging"
D'deploy to staging'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes causes syntax errors.
4fill in blank
hard

Fill both blanks to create a conditional step that deploys only if the branch is 'staging'.

Jenkins
stage('Deploy') {
    when {
        expression { BRANCH_NAME [1] '[2]' }
    }
    steps {
        echo 'Deploying to staging environment'
    }
}
Drag options to blanks, or click blank then click option'
A==
B!=
Cstaging
Dproduction
Attempts:
3 left
💡 Hint
Common Mistakes
Using != or wrong branch names.
5fill in blank
hard

Fill all three blanks to define a pipeline with stages for dev, staging, and prod deployments.

Jenkins
pipeline {
    agent any
    stages {
        stage('[1]') {
            steps {
                echo 'Deploying to development environment'
            }
        }
        stage('[2]') {
            steps {
                echo 'Deploying to staging environment'
            }
        }
        stage('[3]') {
            steps {
                echo 'Deploying to production environment'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Adev
Bstaging
Cprod
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or inconsistent environment names.