tekton-git-listener

by itsmethemojo

Helm chartv0.1.1Verified publisher

generic git repository listener to run tekton pipelines on new commits and/or tags

About this chart

tekton-git-listener

generic git repository listener to run tekton pipelines on new commits and/or tags

Installation with helm

see chart on artifact hub

Local execution

For local usage you need at least yq (see) and git installed. You can then test the functionality of the examples/without_authentification config

KUBECTL_BINARY=./mocks/kubectl ./run.sh

If you have kubectl access to your kubernetes cluster with tekton setup you can also test the pipeline creation locally by not using the mock command

./run.sh

NOTE that the script will create local state data in the tmp folder holding information about already fetched commits/tags. If you want to start from scratch you have to clean up this by.

rm -rf tmp/

generic git repository listener to run tekton pipelines on new commits and/or tags

Values

KeyTypeDefaultDescription
app.command[0]string"bash"
app.command[1]string"/scripts/run.sh"
app.env.CONFIG_DIRstring"/config"Directory to find the listeners.yaml and repositories.yaml in
app.env.CREATE_INITIAL_PIPELINESstring"false"If set to true on the first run pipelines for all matched branch/tags that already exists will be created. If set to false only new commits/tags added after starting this script will be considered.
app.env.DAEMON_MODEstring"true"If set to true this script will periodically run every $PULL_INTERVALL seconds
app.env.DATA_DIRstring"/tmp/data"Directory where current branch/tag ref data is stored to be compared. TODO this should be a PVC
app.env.GIT_CLONE_DIRstring"/tmp/clone"Directory where git repositories will be cloned for watching
app.env.KUBECTL_DOWNLOAD_URIstring"https://dl.k8s.io/release/v1.31.2/bin/linux/amd64/kubectl"To be able to use generic containers, this defines a download URI for the kubectl binary. if left empty the script will use the kubectl binary found in PATH
app.env.PULL_INTERVALLstring"300"Intervall in seconds where all defined repositories will be watched for new commit/tag refs.
app.env.YQ_DOWNLOAD_URIstring"https://github.com/mikefarah/yq/releases/download/v4.27.5/yq_linux_amd64"To be able to use generic containers, this defines a download URI for the yq binary. if left empty the script will use the yqa binary found in PATH
app.env.tmp_dirstring"/tmp/definitions"Directory to store temporary created tekton pipeline run definitions
app.extraVolumeMounts[0].mountPathstring"/scripts"
app.extraVolumeMounts[0].namestring"scripts"
app.extraVolumeMounts[1].mountPathstring"/config"
app.extraVolumeMounts[1].namestring"config"
app.extraVolumes[0].configMap.namestring"tekton-git-listener-scripts"
app.extraVolumes[0].namestring"scripts"
app.extraVolumes[1].namestring"config"
app.extraVolumes[1].secret.secretNamestring"tekton-git-listener-config"
app.fullnameOverridestring"tekton-git-listener"
app.image.repositorystring"buildpack-deps"This image will miss the yq and kubectl binary. You might choose an image with both available and disbale $KUBECTL_DOWNLOAD_URI and $YQ_DOWNLOAD_URI
app.image.tagstring"scm"
app.livenessProbestring""
app.readinessProbestring""
app.serviceAccount.createboolfalse
app.serviceAccount.namestring"tekton-git-listener"make sure this name aligns with base.fullnameOverride
app.startupProbestring""
config.listenerslist[{"pipeline_name":"your-pipeline-run-name","pipeline_run_template":"apiVersion: tekton.dev/v1beta1\nkind: PipelineRun\nmetadata:\n name: __NAME__\nspec:\n pipelineRef:\n name: your-awesome-tekton-pipeline-template\n params:\n - name: repo-url\n value: __URL__\n - name: git-revision\n value: __REVISION__\n - name: branch\n value: __BRANCH__\n","ref_filter":"refs/heads/main","url":"https://github.com/itsmethemojo/tekton-git-listener.git"}]List of watch definitions
config.listeners[0].pipeline_namestring"your-pipeline-run-name"Name prefix of the tekton pipeline run that will be created
config.listeners[0].pipeline_run_templatestring"apiVersion: tekton.dev/v1beta1\nkind: PipelineRun\nmetadata:\n name: __NAME__\nspec:\n pipelineRef:\n name: your-awesome-tekton-pipeline-template\n params:\n - name: repo-url\n value: __URL__\n - name: git-revision\n value: __REVISION__\n - name: branch\n value: __BRANCH__\n"The yaml definition template for the tekton pipeline run that will be created. Make sure you use the __NAME__ placeholder to get a generic name for this pipeline run. Also make use of the __URL__, __REVISION__, __SHORT_REVISION__ and __BRANCH__ placeholders to get run specific inputs.
config.listeners[0].ref_filterstring"refs/heads/main"This filters the refs as displayed in git ls-remote. choose "refs/heads/" to watch only branches, or "refs/tags/" to watch only tags. You can also leave it out completely to watch everything of both.
config.listeners[0].urlstring"https://github.com/itsmethemojo/tekton-git-listener.git"Url has to match the url in the repositories list
config.repositorieslist[{"url":"https://github.com/itsmethemojo/tekton-git-listener.git"}]List of repositories to be watched for new commits/tags. for each you can add the token attribute to use access tokens. TODO the listener pod does not automatically reload on config file changes yet
config.repositories[0].urlstring"https://github.com/itsmethemojo/tekton-git-listener.git"HTTPS clone url of the git repository

Source Code

Requirements

RepositoryNameVersion
https://itsmethemojo.github.io/helm-charts/app(basic-web-app)1.2.1

Update docs

docker run --rm -v $(pwd):/app -w/app jnorwood/helm-docs -t helm-docs-template.gotmpl

Deploy tekton-git-listener with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has tekton-git-listener on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charttekton-git-listener is pinned at v0.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply