
Thinking about this for a minute, realize that you’re writing an execution system that runs command-line instructions as written by a third party. As well as quote() to help escape shell commands and avoid shell injection vulnerabilities. It provides a split() function that’s smart enough to properly format a list given a command-line string. It provides the necessary execute, block, and check behavior we’re looking for, raising a CalledProcessError exception whenever it finds a failure.Īlso of note, the shlex module is a complimentary library that provides some utilities to aid you in making subprocess calls. This run() function is a more recent addition from Python 3.5. We have a choice between call(), check_call(), check_output(), and run(), all of which are wrappers around a lower-level popen() function that can provide more granular process control. We need to execute a command, wait for it to complete, check the exit code, and print any output that goes to stdout or stderr. So let’s look at how Python’s subprocess module helps us in this situation. Most directives supplied in the YAML spec file are lists of shell commands. As well as the docker environment in which it runs and its limitations. They covered the format and location of the build specification file. Previous chapters in the series already established the build directives to implement. Keeping with the principles of simplicity and practicality, today we’ll look at continuing the series on Designing CI/CD Systems with our implementation of the execution script.


There’s an infinite number of ways to implement this step ranging from a simple shell script to a complex task system.

The most crucial step in any continuous integration process is the one that executes build instructions and tests their output. Python engineering docker Cristian Medina
