diff --git a/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb b/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb new file mode 100644 index 0000000000000000000000000000000000000000..a1236b8f2c19404e78d9b9036c452764e0859b22 --- /dev/null +++ b/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Types + module Ci + class PipelineMergeRequestEventTypeEnum < BaseEnum + graphql_name 'PipelineMergeRequestEventType' + description 'Event type of the pipeline associated with a merge request' + + value 'MERGED_RESULT', + 'Pipeline run on the changes from the source branch combined with the target branch.', + value: :merged_result + value 'DETACHED', + 'Pipeline run on the changes in the merge request source branch.', + value: :detached + end + end +end + +Types::Ci::PipelineMergeRequestEventTypeEnum.prepend_mod diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index 81afc7f0f42104559583f1eb19789d6abaed8937..60418fec6c565bf65a5b3aae702322a5978aaf66 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -175,6 +175,9 @@ class PipelineType < BaseObject field :warning_messages, [Types::Ci::PipelineMessageType], null: true, description: 'Pipeline warning messages.' + field :merge_request_event_type, Types::Ci::PipelineMergeRequestEventTypeEnum, null: true, + description: "Event type of the pipeline associated with a merge request." + def detailed_status object.detailed_status(current_user) end diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index ec2cd6ba2242a7a364897e8a427bb1bf160f0daa..ee4b5fd2abe5bfb304425beeded66e71343c819a 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -14449,6 +14449,7 @@ Represents a file or directory in the project repository that has been locked. | <a id="pipelineid"></a>`id` | [`ID!`](#id) | ID of the pipeline. | | <a id="pipelineiid"></a>`iid` | [`String!`](#string) | Internal ID of the pipeline. | | <a id="pipelinejobartifacts"></a>`jobArtifacts` | [`[CiJobArtifact!]`](#cijobartifact) | Job artifacts of the pipeline. | +| <a id="pipelinemergerequesteventtype"></a>`mergeRequestEventType` | [`PipelineMergeRequestEventType`](#pipelinemergerequesteventtype) | Event type of the pipeline associated with a merge request. | | <a id="pipelinepath"></a>`path` | [`String`](#string) | Relative path to the pipeline's page. | | <a id="pipelineproject"></a>`project` | [`Project`](#project) | Project the pipeline belongs to. | | <a id="pipelinequeuedduration"></a>`queuedDuration` | [`Duration`](#duration) | How long the pipeline was queued before starting. | @@ -19188,6 +19189,16 @@ Values for sorting package. | <a id="pipelineconfigsourceenumunknown_source"></a>`UNKNOWN_SOURCE` | Unknown source. | | <a id="pipelineconfigsourceenumwebide_source"></a>`WEBIDE_SOURCE` | Webide source. | +### `PipelineMergeRequestEventType` + +Event type of the pipeline associated with a merge request. + +| Value | Description | +| ----- | ----------- | +| <a id="pipelinemergerequesteventtypedetached"></a>`DETACHED` | Pipeline run on the changes in the merge request source branch. | +| <a id="pipelinemergerequesteventtypemerged_result"></a>`MERGED_RESULT` | Pipeline run on the changes from the source branch combined with the target branch. | +| <a id="pipelinemergerequesteventtypemerge_train"></a>`MERGE_TRAIN` | Pipeline ran as part of a merge train. | + ### `PipelineScopeEnum` | Value | Description | diff --git a/ee/app/graphql/ee/types/ci/pipeline_merge_request_event_type_enum.rb b/ee/app/graphql/ee/types/ci/pipeline_merge_request_event_type_enum.rb new file mode 100644 index 0000000000000000000000000000000000000000..b06a45cbe81031d592fb5a09f2cc89bb6c0dc7a0 --- /dev/null +++ b/ee/app/graphql/ee/types/ci/pipeline_merge_request_event_type_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module EE + module Types + module Ci + module PipelineMergeRequestEventTypeEnum + extend ActiveSupport::Concern + + prepended do + value 'MERGE_TRAIN', 'Pipeline ran as part of a merge train.', value: :merge_train + end + end + end + end +end diff --git a/ee/spec/graphql/ee/types/ci/pipeline_merge_request_type_enum_spec.rb b/ee/spec/graphql/ee/types/ci/pipeline_merge_request_type_enum_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..8d838daecbf5f28d16d0a0671e1087038abdb255 --- /dev/null +++ b/ee/spec/graphql/ee/types/ci/pipeline_merge_request_type_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PipelineMergeRequestEventType'] do + it 'has specific values' do + expect(described_class.values).to match a_hash_including( + 'MERGE_TRAIN' => have_attributes(value: :merge_train) + ) + end +end diff --git a/spec/graphql/types/ci/pipeline_merge_request_event_type_enum_spec.rb b/spec/graphql/types/ci/pipeline_merge_request_event_type_enum_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..3a90e4f1fd9b126dc46b0ce5ef90c9a71d6745c6 --- /dev/null +++ b/spec/graphql/types/ci/pipeline_merge_request_event_type_enum_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PipelineMergeRequestEventType'] do + specify { expect(described_class.graphql_name).to eq('PipelineMergeRequestEventType') } + + it 'has specific values' do + expect(described_class.values).to match a_hash_including( + 'MERGED_RESULT' => have_attributes(value: :merged_result), + 'DETACHED' => have_attributes(value: :detached) + ) + end +end diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index 94d1b42da37b4e5988c4a92c5fb68dc2f8ef8dd7..9dee834d05f916b2cc824d76d1779577b8f24b81 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -14,7 +14,7 @@ coverage created_at updated_at started_at finished_at committed_at stages user retryable cancelable jobs source_job job job_artifacts downstream upstream path project active user_permissions warnings commit commit_path uses_needs - test_report_summary test_suite ref ref_path warning_messages + test_report_summary test_suite ref ref_path warning_messages merge_request_event_type ] if Gitlab.ee?