0
0
Jenkinsdevops~10 mins

Rollback strategies 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 rollback stage in a Jenkins pipeline.

Jenkins
stage('Rollback') {
    steps {
        sh '[1]'
    }
}
Drag options to blanks, or click blank then click option'
Arollback.sh
Becho Rollback initiated
Cdeploy.sh
Dbuild.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Using deploy.sh instead of rollback.sh
Forgetting to use the shell command
Using echo instead of running a script
2fill in blank
medium

Complete the code to trigger rollback only if the deployment fails.

Jenkins
post {
    failure {
        script {
            [1]()
        }
    }
}
Drag options to blanks, or click blank then click option'
Adeploy
Btest
Cbuild
Drollback
Attempts:
3 left
💡 Hint
Common Mistakes
Calling deploy() on failure
Calling build() or test() instead of rollback()
Not calling any function
3fill in blank
hard

Fix the error in the rollback script call to use the correct Jenkins syntax.

Jenkins
steps {
    [1] 'rollback.sh'
}
Drag options to blanks, or click blank then click option'
Ash
BexecuteShell
CrunShell
Dshell
Attempts:
3 left
💡 Hint
Common Mistakes
Using executeShell or runShell which are not Jenkins steps
Using shell instead of sh
4fill in blank
hard

Fill both blanks to define a rollback stage that runs a shell script and echoes a message.

Jenkins
stage('Rollback') {
    steps {
        [1] 'rollback.sh'
        [2] 'Rollback completed successfully'
    }
}
Drag options to blanks, or click blank then click option'
Ash
Becho
Crun
Dscript
Attempts:
3 left
💡 Hint
Common Mistakes
Using run instead of sh
Using script instead of echo
Mixing up the order of commands
5fill in blank
hard

Fill all three blanks to create a rollback stage that runs a script, checks a condition, and echoes a message.

Jenkins
stage('Rollback') {
    steps {
        [1] 'rollback.sh'
        script {
            if (currentBuild.result == '[2]') {
                [3] 'Rollback was successful'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Ash
BSUCCESS
Cecho
DFAILURE
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for SUCCESS instead of FAILURE
Using run instead of sh
Using print instead of echo