From 6fee5aa2680e3bc5956b3db4ff4a34f7a53c1a5a Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 24 Feb 2023 23:00:10 -0700 Subject: [PATCH] Record docker build output in database --- database/db.go | 1 + database/func.go | 13 +++++++++++++ pipeline_executor/pipeline_executor.go | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/database/db.go b/database/db.go index 8a3df1a..a5ba176 100644 --- a/database/db.go +++ b/database/db.go @@ -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, diff --git a/database/func.go b/database/func.go index d7c8227..b481f42 100644 --- a/database/func.go +++ b/database/func.go @@ -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 diff --git a/pipeline_executor/pipeline_executor.go b/pipeline_executor/pipeline_executor.go index d9efd66..f25e040 100644 --- a/pipeline_executor/pipeline_executor.go +++ b/pipeline_executor/pipeline_executor.go @@ -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 {