How jenkinsci/tekton-client-plugin works
Project Type and Purpose
• This is a Jenkins plugin (“tekton-client-plugin”) written in Java.
• Purpose: allow Jenkins Pipelines to create, manage, delete, and monitor Tekton Pipeline resources on one or more Kubernetes clusters, with live log streaming and GitHub Checks integration.
File‐Structure Analysis
• Standard Maven layout (pom.xml, src/main/java, src/main/resources, src/test).
• Under src/main/java/org/waveywaves/jenkins/plugins/tekton you have:
• client package: core Tekton client abstractions (TektonUtils, ToolUtils, HTTP/REST wrappers).
• client/build subpackages: classes to build / create (create/Create*) and delete Tekton resources.
• client/logwatch: classes to tail logs (PipelineRunLogWatch, TaskRunLogWatch).
• client/global: global configuration (ClusterConfig, TektonGlobalConfiguration).
• Under src/main/resources the matching .jelly files define the Jenkins UI forms for each step and the global config screens.
• There are Kubernetes manifests under src/main/kubernetes and example Tekton definitions under src/main/tekton/examples.
• CI/CD and automation scripts: .github/workflows, Jenkinsfile, Dockerfile, Makefile, deploy.sh.
Key README Insights
• Plugin exposes three main Pipeline steps: tektonCreateRaw, tektonCreateCustomTaskRun, tektonDeleteRaw.
• It maps Jenkins environment variables to Tekton parameters, streams live logs, reports status back via GitHub Checks, supports multi‐cluster.
Main Components
a. Jenkins Master
– Plugin itself (loaded as an HPI)
– Global Configuration UI
– Pipeline Step Definitions (Jelly UIs + Java Step implementations)
b. Tekton Client Library
– HTTP/REST client to Kubernetes API server
– Builders for Tekton CRDs (Tasks, TaskRuns, Pipelines, PipelineRuns)
– Log‐watchers
c. Kubernetes Clusters (one or many)
– Tekton Pipelines CRDs & controllers
– Namespaces where resources are created
d. External Integrations
– GitHub (Checks API)
– Tekton Catalog (remote resolution)
Relationships & Data‐Flow
• Jenkins Pipeline invokes a step (e.g. tektonCreateRaw).
• Plugin Step code calls into the Tekton Client Library.
• Client sends REST calls to Kubernetes API server(s), creates or deletes CRDs.
• Tekton controllers in the cluster act on those CRDs and schedule TaskRuns/PipelineRuns.
• LogWatchers subscribe or poll the Pod logs and stream back to Jenkins Console.
• Plugin posts GitHub Check status updates if configured.
• Jenkins environment variables flow into the client as Tekton parameters.
Architectural Patterns & Principles
• Separation of Concerns: UI (Jelly) vs. Step logic vs. Tekton API client.
• Extension Points: Jenkins Step and GlobalConfiguration classes define plugin entry points.
• Builder Pattern: building custom TaskRuns programmatically (classes under build/create).
• Adapter/Wrapper: abstracts away direct Kubernetes client details in TektonUtils, ToolUtils.
• Observer/Listener: log‐watching classes listen for Pod events or logs and push to Jenkins.
Technologies & Frameworks
• Java 8+, Jenkins Plugin API (HPI), Jelly for UI
• Maven for build (pom.xml), Docker for containerizing tests or deployments
• Kubernetes API (client via kubectl or HTTP)
• Tekton CRDs: Task, TaskRun, Pipeline, PipelineRun
• JUnit & MockServer for tests (under src/test)
• GitHub Checks API integration
Final Advice
• How environment variables map into Tekton parameters (optional annotation).