CI/CD - Jenkins pipelines - multichoice questions

Question 1

Choose the correct sentence(s) for an Executor:

Question 2

Given the stage:

stage("Determine new version") {
    steps {
        sh "docker-compose exec -T php-fpm composer --no-ansi --no-interaction tests-ci"
    }

    post {
        always {
            junit "build/junit/*.xml"
            step([
                    $class              : "CloverPublisher",
                    cloverReportDir     : "build/coverage",
                    cloverReportFileName: "clover.xml"
            ])
        }
    }
}

Which of the following lines should be added to the stage{} scope such that the stage would be executed only when the job was originated from branch main?

Question 3

Given:

pipeline {
    agent any

    environment {
        TEST_PREFIX = "test" 
        TEST_IMAGE = "${env.TEST_PREFIX}:${env.BUILD_NUMBER}"
        REGISTRY_AUTH = credentials("docker-registry")
        IS_NEW_VERSION = "YES"
        REGISTRY_ADDRESS = "hub.docker.io"
    }

    stages {
        stage("Login") {
            when {
                environment name: "IS_NEW_VERSION", value: "YES"
            }

            steps {
                script {
                    env.IS_NEW_VERSION = sh(returnStdout: true, script: echo 'NO'").trim()
                }

                sh "docker login -u=$REGISTRY_AUTH_USR -p=$REGISTRY_AUTH_PSW ${env.REGISTRY_ADDRESS}"
            }
        }
        stage("Sample stage") {
            when {
                environment name: "IS_NEW_VERSION", value: "YES"
            }

            steps {                
                sh "echo worked!"
            }
        }
    }
}

Assuming the Login stage has been executed successfully, will the Sample stage stage be executed?

Question 4

Given the following pipeline:

pipeline {
    agent any

    environment {
        IS_NEW_VERSION = "YES"
    }

    stages {
        stage("Deploy to production") {
            when {
                environment name: "IS_NEW_VERSION", value: "YES"
            }

            steps {
                sh "exit 5"
            }

            post {
                success {
                    slackSend(
                            teamDomain: "${env.SLACK_TEAM_DOMAIN}",
                            token: "${env.SLACK_TOKEN}",
                            channel: "${env.SLACK_CHANNEL}",
                            color: "good",
                            message: "${env.STACK_PREFIX} production deploy: *${env.DEPLOY_VERSION}*. <${env.DEPLOY_URL}|Access service> - <${env.BUILD_URL}|Check build>"
                    )
                }

                failure {
                    slackSend(
                            teamDomain: "${env.SLACK_TEAM_DOMAIN}",
                            token: "${env.SLACK_TOKEN}",
                            channel: "${env.SLACK_CHANNEL}",
                            color: "danger",
                            message: "${env.STACK_PREFIX} production deploy failed: *${env.DEPLOY_VERSION}*. <${env.BUILD_URL}|Check build>"
                    )
                }
            }
        }
    }
}

Assuming the Slack Notification was installed and configured properly in the Jenkins server:

Question 5

What is the primary purpose of discarding concurrent builds in a deployment pipeline?

Question 6

You have set up a Jenkins pipline which pushes an image to ERC. Recently, you've noticed that sometimes the pipeline gets stuck due to unavailability or ECR:

The push refers to repository [xxxxxxxxxxx.dkr.ecr.ca-central-1.amazonaws.com/reponame]
714c1b96dd83: Retrying in 1 second 
d2cdc77dd068: Retrying in 1 second 
30aad807caf5: Retrying in 1 second 
0559774c4ea2: Retrying in 1 second 
285b8616682f: Retrying in 1 second 
4aeea0ec2b15: Waiting 
1b1312f842d8: Waiting 
c310009e0ef3: Waiting 
a48777e566d3: Waiting 
2a0c9f28029a: Waiting 

This issues resulted and prolonged blocking of your build and deployment pipelines.

How can you address this issue?

Question 7

You have set up a Jenkins server on a private subnet in your organization's network. Your development team uses GitHub for version control, and you want to trigger Jenkins jobs automatically when code is pushed to the GitHub repository. However, you're facing issues with triggering the jobs due to the Jenkins server's location on the private subnet.

Which method can you use to address this issue effectively?