---
apiVersion: console.openshift.io/v1
kind: ConsoleYAMLSample
metadata:
  name: s2i-build-and-deploy-pipeline
spec:
  targetResource:
    apiVersion: tekton.dev/v1beta1
    kind: Pipeline
  title: s2i-build-and-deploy-pipeline-using-workspace
  description: An example of s2i build and deploy pipeline using workspace
  snippet: false
  yaml: |
    apiVersion: tekton.dev/v1beta1
    kind: Pipeline
    metadata:
      name: s2i-build-and-deploy
    spec:
      params:
        - name: IMAGE_NAME
          type: string
        - name: GIT_REPO
          type: string
        - name: GIT_REVISION
          type: string
      workspaces:
        - name: workspace
      tasks:
        - name: fetch-repository
          taskRef:
            name: git-clone
            kind: ClusterTask
          workspaces:
            - name: output
              workspace: workspace
          params:
            - name: url
              value: $(params.GIT_REPO)
            - name: revision
              value: $(params.GIT_REVISION)
            - name: subdirectory
              value: ""
            - name: deleteExisting
              value: "true"

        - name: build
          taskRef:
            name: s2i-java-8
            kind: ClusterTask
          runAfter:
            - fetch-repository
          workspaces:
            - name: source
              workspace: workspace
          params:
            - name: IMAGE
              value: $(params.IMAGE_NAME)
            - name: TLSVERIFY
              value: "false"

        - name: deploy
          taskRef:
            name: openshift-client
            kind: ClusterTask
          runAfter:
            - build
          params:
            - name: ARGS
              value:
                - "new-app"
                - "--docker-image"
                - "$(params.IMAGE_NAME)"
