Skip to content

Commit 1bffda2

Browse files
committed
feat: Export job exit code
1 parent 55bc923 commit 1bffda2

File tree

8 files changed

+101
-45
lines changed

8 files changed

+101
-45
lines changed

internal/exporter/messages/job.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func NewJob(job types.Job) *typespb.Job {
2626
RefPath: job.RefPath,
2727
Status: job.Status,
2828
FailureReason: job.FailureReason,
29+
ExitCode: job.ExitCode,
2930

3031
Timestamps: &typespb.JobTimestamps{
3132
CreatedAt: timestamppb.New(valOrZero(job.CreatedAt)),

internal/gitlab/graphql/generated.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/gitlab/graphql/graphql.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ func valOrZero[T any](t *T) T {
8383
return v
8484
}
8585

86+
func valOr[T any](t *T, v T) T {
87+
if t != nil {
88+
return *t
89+
}
90+
return v
91+
}
92+
8693
func ptr[T any](v T) *T {
8794
return &v
8895
}

internal/gitlab/graphql/jobs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ func ConvertJob(jf JobFields) (types.Job, error) {
9999
Stage: stage,
100100
Tags: jf.Tags,
101101

102+
ExitCode: int64(valOr(jf.ExitCode, -1)),
103+
102104
QueuedDuration: time.Duration(valOrZero(jf.QueuedDuration) * float64(time.Second)),
103105
Duration: time.Duration(valOrZero(jf.Duration) * int(time.Second)),
104106
Coverage: valOrZero(jf.Coverage),

internal/gitlab/graphql/spec/fragments/jobs.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fragment JobFieldsExtra on CiJob {
2525

2626
tags
2727

28+
exitCode
29+
2830
manualJob
2931
retryable
3032
retried

internal/types/jobs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type Job struct {
4343
Tags []string
4444
Properties []JobLogProperty
4545

46+
ExitCode int64
47+
4648
AllowFailure bool
4749
Manual bool
4850
Retried bool

protobuf/typespb/job.pb.go

Lines changed: 40 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/gitlabexporter/protobuf/job.proto

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,26 @@ message Job {
2424
string ref_path = 5;
2525
string status = 6;
2626
string failure_reason = 7;
27+
int64 exit_code = 8;
2728

28-
JobTimestamps timestamps = 8;
29-
google.protobuf.Duration queued_duration = 9;
30-
google.protobuf.Duration duration = 10;
31-
double coverage = 11;
29+
JobTimestamps timestamps = 9;
30+
google.protobuf.Duration queued_duration = 10;
31+
google.protobuf.Duration duration = 11;
32+
double coverage = 12;
3233

33-
string stage = 12;
34-
repeated string tags = 13;
35-
repeated JobProperty properties = 14;
34+
string stage = 13;
35+
repeated string tags = 14;
36+
repeated JobProperty properties = 15;
3637

37-
bool allow_failure = 15;
38-
bool manual = 16;
39-
bool retried = 17;
40-
bool retryable = 18;
38+
bool allow_failure = 16;
39+
bool manual = 17;
40+
bool retried = 18;
41+
bool retryable = 19;
4142

42-
JobKind kind = 19;
43-
optional PipelineReference downstream_pipeline = 20;
43+
JobKind kind = 20;
44+
optional PipelineReference downstream_pipeline = 21;
4445

45-
RunnerReference runner = 21;
46+
RunnerReference runner = 22;
4647
}
4748

4849
message JobTimestamps {

0 commit comments

Comments
 (0)