Draft: Returns latest pipeline with scheduled PEP graphql
What does this MR do and why?
We want to add the status of the latest pipeline that was created by a scheduled pipeline execution policy to the policy editor. To archive this, the MR introduces a new Ci::GroupPipelinesFinder to query pipelines across group projects and enhances the GraphQL PipelineExecutionSchedulePolicy type with a latestScheduledPipeline field.
Scheduled pipelines are not linked to the policy that created them, so there is no way to tell if the policy actually created the latest pipeline. I marked the new field as experiment so we can test if it is actually helpful.
Solution
New Ci::GroupPipelinesFinder: Provides consistent pipeline querying across group projects with proper authorization, filtering, and sorting Enhanced GraphQL field: Adds latestScheduledPipeline to PipelineExecutionSchedulePolicy type to expose pipeline execution status
References
- Related issue: #528299
- Scheduled pipeline execution policy documentation: https://docs.gitlab.com/user/application_security/policies/scheduled_pipeline_execution_policies/
How to set up and validate locally
- Create a new group.
- Create a new project on the group.
- Add a
.gitlab/security-policies/policy.ymlfile to the project with content (Replacepath/to/projectwith the path to your project):--- experiments: pipeline_execution_schedule_policy: enabled: true pipeline_execution_policy: [] approval_policy: [] pipeline_execution_schedule_policy: - name: test description: '' enabled: true pipeline_config_strategy: schedule content: include: - project: path/to/project file: policy-ci.yml schedules: - type: daily start_time: '10:00' time_window: value: 600 distribution: random - Go back to the group page and on the left sidebar, select Security & Compliance and Policies.
- Select Edit policy project and select your project. Then select Save.
- Start the schedule worker manually to trigger the schedule:
Security::PipelineExecutionPolicies::RunScheduleWorker.new.perform(Security::PipelineExecutionProjectSchedule.last.id) - Open the GraphQL explorer
http://gdk.test:3000/-/graphql-explorer - Run the query for the group you created (replace
group-pathwith the path of your group):query { group(fullPath: "group-path") { pipelineExecutionSchedulePolicies { nodes { name latestScheduledPipeline { id status createdAt } } } } }
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #528299