Refactor to remove duplicate code around BuildArgs Upstream-commit: 24b4c9e7370222a9931678641b5ef7e66c2f6bc0 Component: engine