nerdexam
Cisco

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.

CI/CD Pipelines

Question

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 formatting with the Python script with the Black library. However, when this pipeline runs, Travis CI reports the error: No command 'black' found, did you mean: Command 'slack' from package 'slack' (universe) black: command not found The command "black --check" exited with 127. What must be added to the travis.yml file to fix the error?

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)
  • A
    5% (1)
  • B
    5% (1)
  • C
    18% (4)
  • D
    73% (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.

AAfter script: - pip install pytest

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.

BAfter script: - pip install black

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.

CInstall: - pip install pytest

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`.

DInstall: - pip install blackCorrect

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

#CI/CD Pipelines#Travis CI#Python Development#Dependency Management

Community Discussion

No community discussion yet for this question.

Full 300-910 Practice