300-910 · Question #94
300-910 Question #94: Real Exam Question with Answer & Explanation
This question tests the ability to construct a valid GitLab CI/CD pipeline YAML configuration that uses a Docker image, declares ordered stages, leverages before_script for shared setup, and maps jobs to the correct stages.
Question
Drag and Drop Question. A DevOps engineer is designing a precheck validation of the application infrastructure in a CI/CD pipeline and must implement this workflow: - Use source Docker image named python:latest. - Define three stages named Verify, Install, and Unit Test. - Verify the Python version and install prerequisite packages in the before_script section. - Run the prevalidation script to check the environment in the Verify stage. - Install source code in the Install stage. - Run unit testing in the Unit Test stage. Drag and drop the code snippets from the bottom onto the boxes in the GitLab CI configuration to meet these requirements. Not all options are used.
Explanation
This question tests the ability to construct a valid GitLab CI/CD pipeline YAML configuration that uses a Docker image, declares ordered stages, leverages before_script for shared setup, and maps jobs to the correct stages.
Approach. The correct .gitlab-ci.yml must open with image: python:latest to declare the base Docker image, then define stages: [Verify, Install, Unit Test] in that order to control pipeline execution sequence. A top-level before_script block should contain python --version and a pip prerequisites install command so those steps run before every job automatically. Three jobs are then defined-one per stage-each with a stage: key matching its stage name and a script: block: the Verify job runs the prevalidation script, the Install job installs the source code (e.g., pip install .), and the Unit Test job executes the test runner (e.g., pytest). Placing version verification and prereq installs in before_script (not inside individual job scripts) is the key distinction, as it avoids duplication and ensures the environment is consistent for all stages.
Concept tested. GitLab CI/CD YAML structure: correct use of top-level image, stages, and before_script keywords versus per-job stage and script keywords, and understanding that before_script at the global level runs before every job's script section.
Reference. GitLab CI/CD documentation - 'Keyword reference for the .gitlab-ci.yml file': https://docs.gitlab.com/ee/ci/yaml/
Topics
Community Discussion
No community discussion yet for this question.