Gitlab Merge Request

kind: gitlab/mergerequest

Description

The action section describes the Gitlab Merge Requests that updatecli is expected to open (or update) when a target is modified.

Parameters

NameTypeDescriptionRequired
assigneesarray

“assignees” contains the list of assignee to add to the merge request

default: empty

remark: assignees only accept GitLab User IDs. To find the user ID: 1. Go to the users’ profile page. 2. On the profile page, in the upper-right corner, select Actions (or ⋮). 3. Select Copy user ID.

bodystring

“body” defines a custom mergerequest body

default: By default a mergerequest body is generated out of a pipeline execution.

remark: Unless you know what you are doing, you shouldn’t set this value and rely on the sane default. “body” is useful to provide additional information when reviewing mergerequest, such as changelog url.

labelsarray

“labels” defines labels for the merge request.

default: empty

remark:
	if a label does not already exist, this creates a new project label and assigns it to the merge request
ownerstring

“owner” defines the GitLab repository owner.

remark: unless you know what you are doing, you shouldn’t set this value and rely on the scmid to provide the sane default.

removesourcebranchboolean

“removesourcebranch” is a flag indicating if a merge request should remove the source branch when merging

default: false

repositorystring

“repository” defines the GitLab repository for a specific owner

remark: unless you know what you are doing, you shouldn’t set this value and rely on the scmid to provide the sane default.

reviewersarray

“reviewers” contains the list of reviewers to add to the merge request

default: empty

remark: assignees only accept GitLab User IDs. To find the user ID: 1. Go to the users’ profile page. 2. On the profile page, in the upper-right corner, select Actions (or ⋮). 3. Select Copy user ID.

sourcebranchstring

“sourcebranch” defines the branch name used as a source to create the GitLab mergerequest.

default: “sourcebranch” inherits the value from the scm branch if a scm of kind “gitlab” is specified by the action.

remark: unless you know what you are doing, you shouldn’t set this value and rely on the scmid to provide the sane default.

squashboolean

“squash” defines if all commits should be squashed into a single commit on merge

default: false

remark: project settings might override this value

targetbranchstring

“targetbranch” defines the branch name used as a target to create the GitLab mergerequest.

default: “targetbranch” inherits the value from the scm working branch if a scm of kind “gitlab” is specified by the action.

remark: unless you know what you are doing, you shouldn’t set this value and rely on the scmid to provide the sane default. the GitLab scm will create and use a working branch such as updatecli_xxxx

titlestring

“title” defines the GitLab mergerequest title

default: A GitLab mergerequest title is defined by one of the following location (first match) 1. title is defined by the spec such as:

 			actions:
 				default:
 					kind: gitlab/mergerequest
 					scmid: default
 					spec:
 						title: This is my awesome title

 		2. title is defined by the action such as:

 			actions:
 				default:
 					kind: gitlab/mergerequest
 					scmid default
 					title: This is my awesome title

 		3. title is defined by the first associated target title

 		4. title is defined by the pipeline title

remark: usually we prefer to go with option 2

tokenstring

“token” defines the credential used to authenticate with GitLab

remark: A token is a sensitive information, it’s recommended to not set this value directly in the configuration file but to use an environment variable or a SOPS file.

The value can be set to {{ requiredEnv "GITLAB_TOKEN"}} to retrieve the token from the environment variable GITLAB_TOKEN or {{ .gitlab.token }} to retrieve the token from a SOPS file.

  For more information, about a SOPS file, please refer to the following documentation:

https://github.com/getsops/sops

tokentypestring

“tokentype” defines type of provided token. Valid values are “private” and “bearer”

default: “private”

urlstring

“url” defines the GitLab url to interact with

default: “gitlab.com”

usernamestring“username” defines the username used to authenticate with GitLab

Example

# updatecli.yaml
# updatecli diff --config updatecli.yaml
#
name: Show Gitlab pipeline example

# Sources are responsible to fetch information from third location such as npm registry.
sources:
  updatecli:
    name: Get latest axios version
    kind: npm
    spec:
      name: axios

# Targets are responsible to update targeted files such as a yaml file.
targets:
  npm:
    name: Update e2e test file
    kind: yaml
    sourceid: updatecli
    scmid: gitlab
    spec:
      file: e2e/updatecli.d/success.d/npm.yaml
      key: conditions.axios.spec.version

### 

# Actions such as gitlab/mergerequest is triggered if a target is updated.
actions:
  default:
    title: Bump axios version
    kind: gitlab/mergerequest
    scmid: gitlab

scms:
  gitlab:
    kind: gitlab
    spec:
      owner: "olblak"
      repository: "updatecli"
      branch: main
      # For the change to be apply, we need to specify gitlab credentials
      #username: gitlab_username
      #token: gitlab_token

Top