Skip to content

DrummyFloyd/gitlab-merge-request-resource

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab Merge Request Concourse Resource

A concourse resource to check for new merge requests on GitLab and update the merge request status.

Source Configuration

resource_types:
- name: merge-request
  type: docker-image
  source:
    repository: DrummyFloyd/gitlab-merge-request-resource

resources:
- name: merge-request
  type: merge-request
  source:
    uri: https://gitlab.com/myname/myproject.git
    private_token: XXX
  • uri: (required) The location of the repository (required)
  • private_token: (required) Your GitLab user's private token (required, can be found in your profile settings)
  • insecure: When set to true, SSL verification is turned off
  • skip_drafts: when set to truemerge requests mark as draft will be skipped Default false
  • skip_work_in_progress: When set to true, merge requests mark as work in progress (WIP) will be skipped. Default false
  • skip_not_mergeable: When set to true, merge requests not marked as mergeable will be skipped. Default false
  • skip_trigger_comment: When set to true, the resource will not look up for [trigger ci] merge request comments to manually trigger builds. Default false
  • concourse_url: When set, this url will be used to override ATC_EXTERNAL_URL during commit status updates. No set default.
  • pipeline_name(string): When set, this url will be used to override BUILD_PIPELINE_NAME during commit status updates.
  • labels(string[]): Filter merge requests by label[]
  • paths (string[]): Include merge request if one of the modified file matches a path pattern (glob). Default: include all.
  • ignore_paths (string[]): Exclude merge request if one of the modified files matches a path pattern (glob). Default: exclude none.
  • target_branch(string): Filter merge requests by target_branch. Default is empty string.
  • source_branch(string): Filter merge requests by source_branch. Default is empty string.
  • sort (string): Merge requests sorting order, either asc (default) or desc to reverse.

Behavior

check: Check for new merge requests

Checks if there are new merge requests or merge requests with new commits.

in: Clone merge request source branch

git clones the source branch of the respective merge request.

If you need to retrieve any information about the merge request in your tasks, the script writes the raw API response of the get single merge request call to .git/merge-request.json. The name of the source branch is extracted to .git/merge-request-source-branch for convenience.

out: Update a merge request's merge status

Updates the merge request's merge_status which displays nicely in the GitLab UI and allows to only merge changes if they pass the test.

Parameters

  • repository: The path of the repository of the merge request's source branch (required)
  • name_builder: Useful in the case where the ressource can't access to private fork and update pipeline status, in this case the ressource will write a notes on MR like this:

Hi, i'm <name_builder> builder due to this limitations, i can't update pipeline status.
Build State:
Build URL: here` Default: "Concourse"

  • status: The new status of the merge request (required, can be either pending, running, success, failed, or canceled)
  • labels(string[]): The labels you want add to your merge request
  • comment: Add a comment for MR. Could be an object with text/file fields. If just the file or text is specified it is used to populate the field, if both file and text are specified then the file is substituted in to replace $FILE_CONTENT in the text.

Example

jobs:
- name: sample-merge-request
  plan:
  - get: merge-request
    trigger: true
  - put: merge-request
    params:
      repository: merge-request
      status: running
  - task: unit-test
    file: merge-request/ci/tasks/unit-test.yml
  on_failure:
    put: merge-request
    params:
      repository: merge-request
      status: failed
  on_success:
    put: merge-request
    params:
      repository: merge-request
      status: success
      labels: ['unit-test', 'stage']
      comment:
        file: out/commt.txt
        text: |
          Add new comment.
          $FILE_CONTENT

About

A concourse resource to check for new merge requests on GitLab

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Dockerfile 0.2%