Skip to content

Add mutation for clearing project runner cache

Avielle Wolfe requested to merge 390684-runner-cache-api into master

What does this MR do and why?

Currently, clearing a project's runner cache is only possible via the UI. Users have requested that it be available via an API as well. This commit adds a new RunnerCacheClear GraphQL mutation that can be used to clear a project's runner cache. It requires that the current user have admin_pipeline permissions on the project, which is the same permission used in the UI.

Changelog: added

Issue: #390684 (closed)

How to set up and validate locally

  1. Pick a project and check its jobs_cache_index in the Rails console. It should be nil or an integer.

  2. Run the RunnerCacheClear mutation in graphql-explorer. $projectId must be the Global ID of the project

    mutation RunnerCacheClear($projectId: ProjectID!) {
      runnerCacheClear(input: { projectId: $projectId }) {
        errors
      }
    }
  3. Recheck the project and see that its jobs_cache_index has been incremented. If it was nil it should now be 1. If it was an integer it should now be one higher.

Edited by Avielle Wolfe

Merge request reports