Skip to main content

mb.add_common_files(files...)

Adds one or more local files to common files to the current branch. Common files are shared code for all deployments, and are copied into deployments at deploy time.

Parameters

  • files: Union[str, List[str], Dict[str, str]] The file(s) to add to common files.
    • as str: The path to a single file or directory.
    • as List[str]: Paths to multiple files or directories.
    • as Dict[str, str]: Pairs of file paths or directories. The key is the local file path, the value is the file path in common files.

Returns

No value is returned. A success status message is printed if the command is successful. An exception is thrown if any file path doesn't resolve to a file.

Examples

Add a single common file

mb.add_common_files("utils.py")

Adding multiple common files

mb.add_common_files(["utils.py", "helpers.py"])

Adding a directory to common files

mb.add_common_files("my_lib")

Adding files outside the current working directory

When adding files that are not in the current working directory, you need to map their local paths to the path you want in common. To map /workspace/foo.py locally to simply foo.py in common:

mb.add_common_files({ "/workspace/foo.py": "foo.py" })

Similarly, if you want files outside the current working directory placed into a subdirectory in common files, add the directory to the remote path:

mb.add_common_files({ "/workspace/lib/foo.py": "lib/foo.py" })

See also