#Export directory/file on error

1 messages · Page 1 of 1 (latest)

quasi drift
#

Hi, not sure if what I am doing is somewhat going against the grain of what dagger is designed for but looking for some advice. Essentially I am building a DevelopmentDeploy dagger call and part of this function call it will test some go code. If this errors I want the dagger call to exit with an error so my CI will fail but still have the junit test results available. The only way I seem to see this working is gracefully exiting without an error, check a returned exit status and then running again to pull the artifact out. This would then need me to manually throw an error in CI.

func (d *DaggerDemo) DeployDevelopment(
    ctx context.Context,
    src *dagger.Directory,
) (*dagger.Directory, error) {
     output := dag.Directory()

    result := dag.Golang(src).Test()
    testResult := result.Junit()
    if testResult != nil {
        output = output.WithFile(
            "unit-tests.xml",
            testResult,
        )
    }
    
    _, err = result.Stdout(ctx)
    if err != nil {
        // if I dont return this err then CI will not fail.
        // If I return this I cant get the test result outputs
        return output, err
    }

    // further deployment steps each output artifacts to the output directory

    return output, nil
}

Thanks!

quasi drift
#

Reading #1275080892410499163 message seems its not possible. Be a great functionality otherwise it is relaying on users knowing that it has to be called twice and custom exit codes checked.