300-910 · Question #91
Refer to the exhibit. A network engineer is designing a CI/CD pipeline with Travis CI for a Python script. This CI/CD pipeline automatically runs unit tests with the pytest library and verifies code f
The correct answer is D. Install: - pip install black. The black: command not found error in Travis CI indicates that the black Python package, used for code formatting, was not installed in the build environment before the script phase attempted to execute it.
Question
Options
- AAfter script: - pip install pytest
- BAfter script: - pip install black
- CInstall: - pip install pytest
- DInstall: - pip install black
How the community answered
(22 responses)- A5% (1)
- B5% (1)
- C18% (4)
- D73% (16)
Why each option
The `black: command not found` error in Travis CI indicates that the `black` Python package, used for code formatting, was not installed in the build environment before the `script` phase attempted to execute it.
The `after_script:` phase runs after the main `script` phase, regardless of its success or failure, meaning any installation here would be too late to resolve an error occurring during the `script` execution.
Similar to option A, installing `black` in the `after_script:` phase occurs after the error has already happened during the `script` phase, thus failing to resolve the `command not found` issue.
While `pytest` also needs to be installed, the specific error in the exhibit is `black: command not found`, indicating `black` is the missing dependency, not `pytest`.
The `install:` stage in Travis CI is specifically designed for installing project dependencies that are required before the main `script` stage executes. Placing `pip install black` under the `install:` key ensures that the `black` package is installed and its executable is available in the system's PATH when the `script` phase attempts to run `black --check`.
Concept tested: Travis CI install phase for dependencies
Source: https://docs.travis-ci.com/user/customizing-the-build/#the-build-lifecycle
Topics
Community Discussion
No community discussion yet for this question.