Skip to content

Commit 27b0b85

Browse files
authored
feat: expand GitLab evalContext with the HEAD pipeline for the MR (#97)
1 parent 0b04c12 commit 27b0b85

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

pkg/scm/gitlab/context_valuers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ func (d MergeStatus) AsString() string {
2525
func (d DetailedMergeStatus) AsString() string {
2626
return d.String()
2727
}
28+
29+
// PipelineStatusEnum is a ENUM type
30+
func (d PipelineStatusEnum) AsString() string {
31+
return d.String()
32+
}

schema/gitlab.schema.graphqls

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ enum DetailedMergeStatus {
156156
REQUESTED_CHANGES
157157
}
158158

159+
enum PipelineStatusEnum {
160+
CANCELED
161+
CANCELING
162+
CREATED
163+
FAILED
164+
MANUAL
165+
PENDING
166+
PREPARING
167+
RUNNING
168+
SCHEDULED
169+
SKIPPED
170+
SUCCESS
171+
WAITING_FOR_CALLBACK
172+
WAITING_FOR_RESOURCE
173+
}
174+
159175
input ListMergeRequestsQueryInput {
160176
project_id: ID!
161177
state: MergeRequestState! = "opened"
@@ -337,6 +353,8 @@ type ContextMergeRequest {
337353
DiffStats: [ContextDiffStat!]
338354
"Labels available on this merge request"
339355
Labels: [ContextLabel!] @generated
356+
"Pipeline running on the branch HEAD of the merge request"
357+
HeadPipeline: ContextPipeline
340358

341359
#
342360
# scm-engine customs
@@ -466,3 +484,43 @@ type ContextDiffStat {
466484
"File path, relative to repository root"
467485
Path: String!
468486
}
487+
488+
# https://docs.gitlab.com/ee/api/graphql/reference/#pipeline
489+
type ContextPipeline {
490+
"Indicates if the pipeline is active"
491+
Active: Boolean!
492+
"Specifies if a pipeline can be canceled"
493+
Cancelable: Boolean!
494+
"Indicates if a pipeline is complete"
495+
Complete: Boolean!
496+
"Duration of the pipeline in seconds"
497+
Duration: Int
498+
"The reason why the pipeline failed"
499+
FailureReason: String
500+
"Timestamp of the pipeline's completion"
501+
FinishedAt: Time
502+
"ID of the pipeline"
503+
ID: String!
504+
"Internal ID of the pipeline"
505+
IID: String!
506+
"If the pipeline is the latest one or not"
507+
Latest: Boolean!
508+
"Name of the pipeline"
509+
Name: String
510+
"Relative path to the pipeline's page"
511+
Path: String
512+
"Specifies if a pipeline can be retried"
513+
Retryable: Boolean!
514+
"Timestamp when the pipeline was started"
515+
StartedAt: Time
516+
"Status of the pipeline"
517+
Status: PipelineStatusEnum!
518+
"If the pipeline is stuck"
519+
Stuck: Boolean!
520+
"The total number of jobs in the pipeline"
521+
TotalJobs: Int!
522+
"Timestamp of the pipeline's last activity"
523+
UpdatedAt: Time!
524+
"Indicates if a pipeline has warnings"
525+
Warnings: Boolean!
526+
}

0 commit comments

Comments
 (0)