Defining and creating pipeline resources

PipelineResources are artifacts that are used as inputs to a Task and can be output by a Task.

Procedure

After you create Task`s, create `PipelineResources that contain the specifics of the Git repository and the image registry to be used in the Pipeline during execution as follows:

  1. Create a resources.yaml file and with the `PipelineResource`s that contain the specifics of the Git repository and the image registry to be used in the pipeline during execution.

    1. Create a PipelineResource that defines the Git repository for the frontend application:

      apiVersion: tekton.dev/v1alpha1
      kind: PipelineResource
      metadata:
        name: ui-repo
      spec:
        type: git
        params:
          - name: url
            value: http://github.com/openshift-pipelines/vote-ui.git
    2. Create a PipelineResource that defines the OpenShift internal image registry to which you want to push the frontend image:

      apiVersion: tekton.dev/v1alpha1
      kind: PipelineResource
      metadata:
        name: ui-image
      spec:
        type: image
        params:
          - name: url
            value: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/ui:latest
    3. Create a PipelineResource that defines the Git repository for the backend application:

      apiVersion: tekton.dev/v1alpha1
      kind: PipelineResource
      metadata:
        name: api-repo
      spec:
        type: git
        params:
          - name: url
            value: http://github.com/openshift-pipelines/vote-api.git
    4. Create a PipelineResource that defines the OpenShift internal image registry to which you want to push the backend image:

      apiVersion: tekton.dev/v1alpha1
      kind: PipelineResource
      metadata:
        name: api-image
      spec:
        type: image
        params:
          - name: url
            value: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/api:latest
  2. Create the Pipeline Resources:

    $ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/pipeline/resources.yaml
  3. See the list of resources:

    $ tkn resource ls
    
    NAME        TYPE    DETAILS
    api-repo    git     url: http://github.com/openshift-pipelines/vote-api.git
    ui-repo     git     url: http://github.com/openshift-pipelines/vote-ui.git
    api-image   image   url: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/api:latest
    ui-image    image   url: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/ui:latest