# auto generated by script/update-tasks.sh
# DO NOT EDIT: use the script instead
# source: https://raw.githubusercontent.com/openshift/pipelines-catalog/release-v0.22/task/s2i-java/0.1/s2i-java.yaml
#
---
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: s2i-java
  labels:
    app.kubernetes.io/version: "0.1"
  annotations:
    tekton.dev/pipelines.minVersion: "0.19"
    tekton.dev/tags: s2i, java, workspace
    tekton.dev/displayName: "s2i java"
spec:
  description: >-
    s2i-java task clones a Git repository and builds and
    pushes a container image using S2I and a Java builder image.

  results:
    - name: IMAGE_DIGEST
      description: Digest of the image just built.
  params:
    - name: VERSION
      description: The tag of java imagestream for java version
      default: 'openjdk-11-ubi8'
      type: string
    - name: PATH_CONTEXT
      description: The location of the path to run s2i from
      default: .
      type: string
    - name: TLSVERIFY
      description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
      default: "true"
      type: string
    - name: MAVEN_ARGS_APPEND
      description: Additional Maven arguments
      default: ""
      type: string
    - name: MAVEN_CLEAR_REPO
      description: Remove the Maven repository after the artifact is built
      default: "false"
      type: string
    - name: MAVEN_MIRROR_URL
      description: The base URL of a mirror used for retrieving artifacts
      default: ""
      type: string
    - name: IMAGE
      description: Location of the repo where image has to be pushed
      type: string
    - name: BUILDER_IMAGE
      description: The location of the buildah builder image.
      default: registry.redhat.io/rhel8/buildah@sha256:6a68ece207bc5fd8db2dd5cc2d0b53136236fb5178eb5b71eebe5d07a3c33d13
  workspaces:
    - name: source
      mountPath: /workspace/source
  steps:
    - name: gen-env-file
      image: registry.redhat.io/ocp-tools-4-tech-preview/source-to-image-rhel8@sha256:ba51e5e74ff5a29fd429b0bb77bc2130e5284826a60d042fc4e4374381a7a308
      workingDir: /env-params
      command:
        - '/bin/sh'
        - '-c'
      args:
        - |-
          echo "MAVEN_CLEAR_REPO=$(params.MAVEN_CLEAR_REPO)" > env-file

          [[ '$(params.MAVEN_ARGS_APPEND)' != "" ]] &&
            echo "MAVEN_ARGS_APPEND=$(params.MAVEN_ARGS_APPEND)" >> env-file

          [[ '$(params.MAVEN_MIRROR_URL)' != "" ]] &&
            echo "MAVEN_MIRROR_URL=$(params.MAVEN_MIRROR_URL)" >> env-file

          echo "Generated Env file"
          echo "------------------------------"
          cat env-file
          echo "------------------------------"
      volumeMounts:
        - name: envparams
          mountPath: /env-params
    - name: generate
      image: registry.redhat.io/ocp-tools-4-tech-preview/source-to-image-rhel8@sha256:ba51e5e74ff5a29fd429b0bb77bc2130e5284826a60d042fc4e4374381a7a308
      workingDir: $(workspaces.source.path)
      command:
        - 's2i'
        - 'build'
        - '$(params.PATH_CONTEXT)'
        - 'image-registry.openshift-image-registry.svc:5000/openshift/java:$(params.VERSION)'
        - '--image-scripts-url'
        - 'image:///usr/local/s2i'
        - '--as-dockerfile'
        - '/gen-source/Dockerfile.gen'
        - '--environment-file'
        - '/env-params/env-file'
      volumeMounts:
        - name: gen-source
          mountPath: /gen-source
        - name: envparams
          mountPath: /env-params
    - name: build
      image: $(params.BUILDER_IMAGE)
      workingDir: /gen-source
      command: ['buildah', 'bud', '--storage-driver=vfs', '--tls-verify=$(params.TLSVERIFY)', '--layers', '-f', '/gen-source/Dockerfile.gen', '-t', '$(params.IMAGE)', '.']
      volumeMounts:
        - name: varlibcontainers
          mountPath: /var/lib/containers
        - name: gen-source
          mountPath: /gen-source
    - name: push
      image: $(params.BUILDER_IMAGE)
      workingDir: $(workspaces.source.path)
      command: ['buildah', 'push', '--storage-driver=vfs', '--tls-verify=$(params.TLSVERIFY)', '--digestfile=$(workspaces.source.path)/image-digest', '$(params.IMAGE)', 'docker://$(params.IMAGE)']
      volumeMounts:
        - name: varlibcontainers
          mountPath: /var/lib/containers
    - name: digest-to-results
      image: $(params.BUILDER_IMAGE)
      script: cat $(workspaces.source.path)/image-digest | tee /tekton/results/IMAGE_DIGEST
  volumes:
    - name: varlibcontainers
      emptyDir: {}
    - name: gen-source
      emptyDir: {}
    - name: envparams
      emptyDir: {}
