I'm running into a design limitation with Dagger. I have an npm audit step that looks like this
await client
.container()
.from('AUDITING_IMAGE')
.withEnvVariable('SEVERITY_THRESHOLD', 'critical')
.withEntrypoint(['/bin/sh', '-c'])
.withExec('node /npm-audit-script.js')
.file('/npm-report.html')
.export('./vulnerability_reports/npm-report.html');
I want the the container to export the report showing a failed scan whilst returning the exit code of the command. However, this is not possible as Dagger will halt execution if a non-zero code is returned.
What I have tried to do is capture the exit code into a variable. However, this won't work either as you can't chain exitCode after an export call (or vice versa).
This looks related: https://github.com/dagger/dagger/issues/3192
What are my options? All I can think of is writing the exit code into a file and handling it outside of Dagger, but that feels wrong...
Maybe I'm not explaining this clearly. What happens is this: