1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-22 06:02:51 +00:00
catalog/task/gitlab-add-label/0.1
PuneetPunamiya df881aaadc This patch splits gitlab-add-label task from the gitlab directory
Changes include:
  - moves gitlab-add-label task to the task directory
  - rename the yaml filename to match the resource name

Issue: #386

Signed-off-by: Puneet Punamiya <ppunamiy@redhat.com>
2020-07-13 13:41:58 +01:00
..
gitlab-add-label.yaml This patch splits gitlab-add-label task from the gitlab directory 2020-07-13 13:41:58 +01:00
README.md This patch splits gitlab-add-label task from the gitlab directory 2020-07-13 13:41:58 +01:00

GitLab

A collection of tasks to help working with the GitLab API.

GitLab token

Most tasks would expect to have a secret set in the kubernetes secret gitlab with a GitLab token in the key token. Check this to get personal access token for Gitlab. You can easily create it on the command line with kubectl like this :

kubectl create secret generic github --from-literal token="MY_TOKEN"

or

apiVersion: v1
kind: Secret
metadata:
  name: gitlab
type: Opaque
stringData:
  token: $(personal_access_token)

Add labels to the GitLab issue or Merge Request

This task can be used to add labels to the gitlab issue or merge request (pull request).

Install the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/gitlab-add-label/0.1/gitlab-add-label.yaml

Parameters

  • GITLAB_HOST_URL: The Gitlab host(default:gitlab.com).
  • API_PATH_PREFIX: The API path prefix (default.:api/v4).
  • REQUEST_URL: The Gitlab issue or merge request URL where we want to add labels (e.g.https://gitlab.com/foo/bar/issues/10).
  • LABELS: The actual labels to add.
  • GITLAB_TOKEN_SECRET: The name of the secret holding the gitlab-token (default:gitlab).
  • GITLAB_TOKEN_SECRET_KEY: The name of the secret key holding the gitlab-token (default:token).

Secrets

  • Secret to provide Gitlab access token to authenticate to the Gitlab.

Usage

This task expects a secret named gitlab to exist, with a Gitlab token in token with enough privileges to add label to an issue.

To add labels to an issue or merge request, put all the required params, add required secrets and labels will be created.

Taskrun can be created as follows:

apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: gitlab-add-label-run
spec:
  taskRef:
    name: gitlab-add-label
  params:
    - name: REQUEST_URL
      value: https://gitlab.com/Divyanshu42/aws-cli/-/issues/1  # or https://gitlab.com/Divyanshu42/aws-cli/-/merge_requests/1
    - name: LABELS
      value: 
        - bug
        - kind/feature