Record docker build output in database

This commit is contained in:
restitux 2023-02-24 23:00:10 -07:00
parent b475631df6
commit 6fee5aa268
3 changed files with 20 additions and 1 deletions

View File

@ -149,6 +149,7 @@ CREATE TABLE runs (
id UUID PRIMARY KEY,
pipeline UUID,
in_progress BOOLEAN DEFAULT NULL,
build_output TEXT DEFAULT NULL,
result BIGINT DEFAULT NULL,
stdout TEXT DEFAULT NULL,
stderr TEXT DEFAULT NULL,

View File

@ -295,6 +295,19 @@ RETURNING id, pipeline, in_progress;`
return run, nil
}
func (db *Database) UpdateRunBuildOutput(runId uuid.UUID, buildResult string) error {
query := `
UPDATE runs
SET build_output=$1
WHERE id=$2;`
_, err := db.Conn.Exec(context.Background(),
query, buildResult, runId)
return err
}
func (db *Database) UpdateRunResult(r Run) error {
query := `
UPDATE runs

View File

@ -146,7 +146,12 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
log.Errorf("could no read build response: %w", err)
return
}
log.Debugf("build log: %v", string(response))
err = db.UpdateRunBuildOutput(pe.Run.Id, string(response))
if err != nil {
log.Errorf("could not update build output for run: %w", err)
return
}
err = buildResponse.Body.Close()
if err != nil {