1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-25 06:17:50 +00:00
catalog/task/gitlab-add-label/0.1
PuneetPunamiya 5a3e5f630f Adds category field as an annotation as tekton.dev/categories
- Initially all tags were mapped to categories in Hub,
     for e.g. config.yaml: https://github.com/tektoncd/hub/blob/master/config.yaml,
     so whenever a new tag was added in a task it was mapped to a category called `others`.
     Hence before every release we had to manually map these new tags to some category,
     hence after the discussion in Catalog and Hub WG, a proposal was created for adding
     a category as an annotation.

   - PR to update the TEP-0003-Tekton Catalog Organization: https://github.com/tektoncd/community/pull/352

Signed-off-by: Puneet Punamiya <ppunamiy@redhat.com>
2021-07-26 13:15:08 +01:00
..
gitlab-add-label.yaml Adds category field as an annotation as tekton.dev/categories 2021-07-26 13:15:08 +01:00
README.md Improves url links in the README 2021-05-24 17:47:52 +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/main/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