Git resource

A Git resource represents a Git repository, that contains the source code to be built by the pipeline. Adding the Git resource as an input to a Task clones the repository and allows the Task to perform the required actions.

To create a Git resource using the PipelineResource CRD, use the following as an example:

apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: sample_name
  namespace: default
spec:
  type: git
  params:
    - name: URL
      value: https://github.com/URL_address.git
    - name: revision
      value: master

The following resources can be added:

  • URL: represents the location of the Git repository. You can use this to change the repository.

  • revision: You can use Git revision to control which commit or branch is used. If a revision is not specified, the resource will default to latest from master.

Using a fork

The URL parameter can be used to point to any Git repository. The following example uses a GitHub fork at master:

spec:
  type: git
  params:
    - name: URL
      value: https://github.com/URL_address.git

Using a branch

You can use a revision to create a Git PipelineResource that points to a branch. The following is an example:

spec:
  type: git
  params:
    - name: URL
      value: https://github.com/URL_address.git
    - name: revision
      value: branch_name

To point to a pull request, you can use the pull requests’s branch and reference number:

spec:
  type: git
  params:
    - name: URL
      value: https://github.com/URL_address.git
    - name: revision
      value: refs/pull/1111/head