Skip to content

WIP: Expose merge ref and proper repo_url to runner

What does this MR do?

This is a rails counter-part for gitlab-runner#3983 (closed). It exposes refspecs for merge requests via refspec attribute. The composed specs will look like this

  • +refs/merge-requests/1/head:refs/merge-requests/1/head
  • +refs/merge-requests/1/merge:refs/merge-requests/1/merge

Runner side will fetch source with the given refspecs and checkout the relevant code with the given SHA.

NOTE: This implementation requires the new version of GitLab-Runner. Therefore, we show errors on job details page in case users use an old runner.

Sample response on POST jobs/request

When the job is associated with a merge request. ".../head" or "../merge" will be passed

{
   "id":6591,
   "token":"qjEvjQVZzJtsyY_2xgqx",
   "allow_git_fetch":true,
   "job_info":{
      "name":"build",
      "stage":"test",
      "project_id":89,
      "project_name":"prospective-merge-pipelines"
   },
   "git_info":{
      "repo_url":"http://gitlab-ci-token:qjEvjQVZzJtsyY_2xgqx@localhost:8181/root/prospective-merge-pipelines.git",
      "sha":"5b9b19cd1b6ee9fdce2f7ddb852f7878b8ce6d4a",
      "before_sha":"0000000000000000000000000000000000000000",
      "ref":"patch-1",
      "ref_type":"merge_request",
      "refspecs":[
         "+refs/merge-requests/5/head:refs/merge-requests/5/head"
      ],
      "depth":3
   },
   "runner_info":{
      "timeout":null,
      "runner_session_url":null
   },
...
}

What are the relevant issue numbers?

Related: https://gitlab.com/gitlab-org/gitlab-ee/issues/7380

Does this MR meet the acceptance criteria?

Edited by Shinya Maeda

Merge request reports