Using Git Connector in Tekton Task

Using Git Connector in Tekton Tasks enables centralized management of tool integration information and secure access to Git repositories during Tekton Task execution. Currently, Git Connector only supports BasicAuth authentication method and does not support SSH authentication.

TOC

Requirements for Tekton Task

Not all Tekton Tasks can use Git Connector.

Git Connector essentially injects temporary Git credentials through a CSI Driver. It provides a configuration named gitconfig that generates a .gitconfig file with temporary authentication and URL rewriting settings. For example:

[http]
    extraHeader = Authorization: Basic OmV5Smhixxxxxxxxx==
[url "http://c-git-connector.git-connector-demo.svc]
    insteadOf = https://github.com

Therefore, Tekton Tasks must meet the following requirement to use Git Connector:

Support mounting a .gitconfig file via Workspace, and the Workspace must support providing only the .gitconfig file

Usage Instructions

After confirming that your Tekton Task can use Git Connector, you can add Git Connector configuration to the TaskRun YAML file:

For example:

apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
  name: git-clone-demo
spec:
  # .  . .
  workspaces:
  - name: basic-auth
    csi:
      driver: connectors-csi
      readOnly: true
      volumeAttributes:
        connector.name: github
        connector.namespace: ""
        configuration.names: "gitconfig"

Parameter descriptions:

  • name: The Workspace name defined in the Task
  • csi:
    • driver: Fixed value connectors-csi
    • readOnly: Fixed value true
    • volumeAttributes: CSI Volume attributes
      • connector.name: Name of the Git Connector
      • connector.namespace: Namespace of the Git Connector; if not specified, the TaskRun's namespace is used
      • configuration.names: Configuration name, fixed as gitconfig, which will generate a .gitconfig file in the $(workspaces.basic-auth.path) directory

For more information, please refer to Connectors CSI Configuration.

Further Reading