{{ if has "gitlab" .Values.global.gitProviders }}
{{ if .Values.pipelines.deployableResources.opa }}
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: gitlab-opa-opa-lib-build-default
  labels:
    app.edp.epam.com/pipelinetype: build
    {{- include "edp-tekton.labels" . | nindent 4 }}
spec:
  description: "The Build pipeline for building OPA library (default versioning)"
  workspaces:
    - name: shared-workspace
    - name: ssh-creds
  params:
    - name: gitfullrepositoryname
      description: "repository full name"
      type: string
    - name: pipelineUrl
      default: https://portal-{{ .Release.Namespace }}.{{ .Values.global.dnsWildCard }}/c/main/pipelines/$(context.pipelineRun.namespace)/$(context.pipelineRun.name)
      type: string
    - name: git-source-url
      default: "https://github.com/epmd-edp/rego-opa-opa"
      description: git url to clone
      type: string
    - name: git-source-revision
      description: 'git revision to checkout (branch, tag, sha, ref…)'
      default: "master"
      type: string
    - name: CODEBASE_NAME
      default: 'rego-opa'
      description: "Project name"
      type: string
    - name: changeNumber
      description: Change number from Merge Request
      default: ""
      type: string
    - name: image
      default: '{{ include "edp-tekton.registry" . }}/openpolicyagent/opa:0.45.0-debug'
      description: "opa image version"
      type: string
    - name: TICKET_NAME_PATTERN
      description: "Ticket name pattern"
      default: ""
    - name: COMMIT_MESSAGE_PATTERN
      description: "Pattern to validate a commit message"
      default: ""
    - name: COMMIT_MESSAGE
      description: "Commit message"
      default: ""
    - name: JIRA_ISSUE_METADATA_PAYLOAD
      description: "Jira Payload"
      default: ""
    - name: JIRA_SERVER
      description: "Jira server name"
      default: ""

{{- include "build-result" . | nindent 2 }}

  tasks:

{{- include "gitlab-build-start" . | nindent 4 }}

    - name: get-version
      taskRef:
        kind: Task
        name: get-version-default
      runAfter:
        - init-values
      params:
        - name: BRANCH_NAME
          value: $(params.git-source-revision)

{{- include "opa-build-common" . | nindent 4 }}

{{ include "finally-block-default" . | nindent 2 }}

{{ include "gitlab-build-vote" . | nindent 4 }}

{{ end }}
{{ end }}
