I am performing a git diff in one container and then including that file in the other container.
But dagger prints the whole file content into the log, which is not acceptable within our CI/CD pipeline.
Setting the silent option hides all other output as well e.g. hiding the test results which are send to stdout.
There was the same question before: #1349120663884926986 message
But without any real answer on the actual question.
@staticmethod
async def execute_git_command(root_dir: "dagger.Directory", command: list[str]) -> str:
"""Execute a generic git command using a Dagger container."""
output_file = "/tmp/output.txt" # noqa: S108
output = (
await MonorepoDagger.git_container(root_dir)
.with_exec(command, redirect_stdout=output_file)
.file(output_file)
.contents()
)
return output.strip()
This will print the file content to the log.
This then is included in the other container:
.with_file("diff.txt", dag.file("diff.txt", contents=git_diff))
Which prints the file content to the log again.
How to avoid this? What is the recommended approach?