GSoC25-tekton-plugin
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Jenkins Tekton Plugin - Feature Documentation The Jenkins Tekton Plugin enables Jenkins to interact with Tekton Pipelines running on Kubernetes clusters. It provides build steps for creating, managing, and monitoring Tekton resources directly from Jenkins pipelines. ## Part 1: Tekton Resource Creation ### 1. Raw Resource Creation (`CreateRaw` class) #### Core Creation Functions: **`createTask(InputStream inputStream): String`** - Loads Task from input stream using taskClient - Sets namespace if provided and not already specified in resource - Creates Task in specified or default namespace - Returns: Resource name of created Task **`createTaskRun(InputStream inputStream): String`** - Loads TaskRun from input stream using taskRunClient - Sets namespace if provided and not already specified in resource - Creates TaskRun in specified or default namespace - Calls `streamTaskRunLogsToConsole()` for real-time log monitoring - Returns: Resource name of created TaskRun - Throws: Exception if TaskRun execution fails **`createPipeline(InputStream inputStream): String`** - Loads Pipeline from input stream using pipelineClient - Sets namespace if provided and not already specified in resource - Creates Pipeline in specified or default namespace - Returns: Resource name of created Pipeline **`createPipelineRun(InputStream inputStream, EnvVars envVars): String`** - Loads PipelineRun from input stream using pipelineRunClient - Sets namespace if provided and not already specified in resource - Calls `enhancePipelineRunWithEnvVars()` to inject Jenkins environment variables - Creates PipelineRun and publishes GitHub-style checks status - Calls `streamPipelineRunLogsToConsole()` for real-time log monitoring - Reloads PipelineRun to check final status conditions - Returns: Resource name of created PipelineRun - Throws: Exception if PipelineRun has failed status condition **`createWithResourceSpecificClient(TektonResourceType resourceType, InputStream inputStream, EnvVars envVars): String`** - Router method that delegates to specific creation functions based on resource type - Switch statement handles: task, taskrun, pipeline, pipelinerun - Returns: Result from specific creation function - Throws: Exception from underlying creation methods #### Input Processing Functions: **`runCreate(Run<?, ?> run, FilePath workspace, EnvVars envVars): String`** - Main orchestration method for resource creation - Handles input type processing (URL, YAML, FILE) - Downloads data from URL or reads from file/YAML content - Calls `convertTektonData()` for catalog processing if enabled - Uses `getKindFromInputStream()` to detect resource type - Delegates to `createWithResourceSpecificClient()` - Handles error reporting and build status setting - Publishes GitHub checks for PipelineRuns - Returns: Name of created resource **`convertTektonData(FilePath workspace, EnvVars envVars, File inputFile, byte[] data): byte[]`** - Processes Tekton resources for catalog integration - Handles remote workspace file copying - Calls `processTektonCatalog()` if enableCatalog is true - Returns: Processed YAML data as byte array - Throws: Exception if catalog processing fails **`processTektonCatalog(EnvVars envVars, File dir, File file, byte[] data): byte[]`** - Executes jx-pipeline-effective binary to resolve `uses:` syntax - Creates temporary input/output files - Builds ProcessBuilder with environment variables - Executes binary and captures exit code - Logs process output using `LogUtils.logStream()` - Returns: Processed YAML data with resolved external references - Throws: Exception if binary execution fails (exit code != 0) #### Environment Variable Functions: **`enhancePipelineRunWithEnvVars(PipelineRun pr, EnvVars envVars): void`** - Maps Jenkins environment variables to PipelineRun parameters - Mappings: - `BUILD_ID` → `BUILD_ID` - `JOB_NAME` → `JOB_NAME` - `GIT_COMMIT` → `PULL_PULL_SHA` - `GIT_BRANCH` → `PULL_BASE_REF` (extracts branch name from refs/origin/branch) - `GIT_URL` → `REPO_URL`, `REPO_OWNER`, `REPO_NAME` - Calls `setParamOnPipelineRunSpec()` for each parameter **`setParamOnPipelineRunSpec(PipelineRunSpec spec, String paramName, String paramValue): void`** - Sets or updates parameter on PipelineRunSpec - Creates params list if it doesn't exist - Updates existing parameter or adds new one - Handles null values by setting empty string **`removeGitSuffix(String part): String`** - Removes `.git` suffix from repository names - Used when parsing `GIT_URL` for `REPO_NAME` parameter #### Log Streaming Functions: **`streamTaskRunLogsToConsole(TaskRun taskRun): void`** - Creates TaskRunLogWatch instance - Starts new thread for log watching - Waits for thread completion using `join()` - Propagates exceptions from log watch thread - Throws: Exception if log streaming fails **`streamPipelineRunLogsToConsole(PipelineRun pipelineRun): void`** - Creates PipelineRunLogWatch instance - Starts new thread for log watching - Waits for thread completion using `join()` - Propagates exceptions from log watch thread - Throws: Exception if log streaming fails ### 2. Custom TaskRun Creation (`CreateCustomTaskrun` class) #### Creation Functions: **`runCreate(): void`** - Main creation method for custom TaskRun - Creates ObjectMeta with name, namespace, generateName - Creates TaskRef pointing to specified task - Builds TaskRunSpec with taskRef, workspaces, and params - Uses TaskRunBuilder to construct complete TaskRun - Creates TaskRun using taskRunClient - Logs created resource name to console **`paramsToParamList(): List<Param>`** - Converts List<TektonParam> to List<Param> - Creates Param objects with name and ArrayOrString value - Handles string parameter values - Returns: List of Tekton Param objects **`workspacesToWorkspaceBindingList(): List<WorkspaceBinding>`** - Converts List<TektonWorkspaceBind> to List<WorkspaceBinding> - Creates WorkspaceBinding objects with name and PersistentVolumeClaimVolumeSource - Sets readOnly=false for all PVC bindings - Returns: List of WorkspaceBinding objects **`logTektonTaskrun(): void`** - Logs TaskRun configuration to Jenkins console - Outputs: Kind, Name, Namespace, TaskRef - Used for debugging and transparency ## Part 2: Tekton Resource Deletion ### 1. Raw Resource Deletion (`DeleteRaw` class) #### Core Deletion Functions: **`deleteTask(): Boolean`** - Lists all Task resources using taskClient.list().getItems() - If resourceName is null: deletes all tasks using `taskClient.delete(taskList)` - If resourceName provided: - Iterates through task list to find matching name - Deletes specific task using `taskClient.delete(task)` - Returns: Boolean indicating successful deletion **`deleteTaskRun(): Boolean`** - Lists all TaskRun resources using taskRunClient.list().getItems() - If resourceName is null: deletes all task runs using `taskRunClient.delete(taskRunList)` - If resourceName provided: - Iterates through task run list to find matching name - Deletes specific task run using `taskRunClient.delete(taskRun)` - Returns: Boolean indicating successful deletion **`deletePipeline(): Boolean`** - Lists all Pipeline resources using pipelineClient.list().getItems() - If resourceName is null: deletes all pipelines using `pipelineClient.delete(pipelineList)` - If resourceName provided: - Iterates through pipeline list to find matching name - Deletes specific pipeline using `pipelineClient.delete(pipeline)` - Returns: Boolean indicating successful deletion **`deletePipelineRun(): Boolean`** - Lists all PipelineRun resources using pipelineRunClient.list().getItems() - If resourceName is null: deletes all pipeline runs using `pipelineRunClient.delete(pipelineRunList)` - If resourceName provided: - Iterates through pipeline run list to find matching name - Deletes specific pipeline run using `pipelineRunClient.delete(pipelineRun)` - Returns: Boolean indicating successful deletion **`deleteWithResourceSpecificClient(TektonResourceType resourceType): boolean`** - Router method that delegates to specific deletion functions - Switch statement handles: task, taskrun, pipeline, pipelinerun - Returns: Result from specific deletion function (boolean) **`runDelete(): boolean`** - Main orchestration method for resource deletion - Calls `deleteWithResourceSpecificClient()` with configured resource type - Returns: Boolean indicating deletion success ## Part 3: Infrastructure Functions ### Resource Detection: **`TektonUtils.getKindFromInputStream(InputStream inputStream, String inputType): List<TektonResourceType>`** - Reads input stream and converts to string - Splits YAML content by line separator - Searches for lines starting with "kind" - Extracts kind value and converts to lowercase - Maps to TektonResourceType enum values - Returns: List of detected resource types - Handles: IOException during stream reading ### Client Management: **`TektonUtils.initializeKubeClients(Config config): void`** - Creates TektonClient and KubernetesClient from config - Stores clients in static maps with DEFAULT_CLIENT_KEY - Thread-safe using synchronized methods **`TektonUtils.initializeKubeClients(List<ClusterConfig> clusterConfigs): void`** - Creates clients for multiple cluster configurations - Builds Config objects from ClusterConfig (masterUrl, namespace) - Stores clients in maps using cluster name as key - Adds default clients if not present **`TektonUtils.shutdownKubeClients(): void`** - Closes all TektonClient and KubernetesClient instances - Iterates through client maps and calls close() on each - Thread-safe cleanup of resources ### Utility Functions: **`LogUtils.logStream(InputStream in, Logger logger, boolean error): void`** - Reads input stream line by line using LineReader - Logs each line to specified logger - Uses Level.WARNING for error streams, Level.INFO for regular streams - Handles: IOException during stream reading **`ToolUtils.getJXPipelineBinary(ClassLoader classLoader): String`** - Detects platform (Linux, macOS, Windows) using SystemUtils - Extracts appropriate jx-pipeline-effective binary from classpath - Creates temporary file and copies binary content - Sets executable permissions on binary file - Returns: File path to executable binary - Throws: IOException if extraction or permission setting fails ## Part 4: Dependencies and Libraries ### Core Tekton/Kubernetes Libraries - **fabric8 Kubernetes Client** (`io.fabric8.kubernetes`) - `DefaultKubernetesClient` - Main Kubernetes API client - `Config`, `ConfigBuilder` - Kubernetes cluster configuration - Custom Resource Definition support - **fabric8 Tekton Client** (`io.fabric8.tekton`) - `DefaultTektonClient` - Tekton-specific API client - `TektonClient` - Interface for Tekton operations - Tekton v1beta1 API models: - `Task`, `TaskList`, `TaskRun`, `TaskRunList` - `Pipeline`, `PipelineList`, `PipelineRun`, `PipelineRunList` - `Param`, `ArrayOrString`, `WorkspaceBinding` ### Jenkins Core Libraries - **Hudson/Jenkins Core** - `hudson.tasks.Builder` - Base class for build steps - `hudson.model.Run`, `hudson.model.TaskListener` - `hudson.FilePath`, `hudson.Launcher` - `hudson.EnvVars` - Environment variable handling - **Jenkins Pipeline Support** - `jenkins.tasks.SimpleBuildStep` - Pipeline step interface - `org.jenkinsci.Symbol` - Pipeline step annotations - **Jenkins Checks API** (`io.jenkins.plugins.checks.api`) - `ChecksPublisher`, `ChecksDetails`, `ChecksOutput` - `ChecksStatus`, `ChecksConclusion` - GitHub-style status reporting ### Utility Libraries - **Google Guava** - `com.google.common.io.LineReader` - Line-by-line stream reading - `com.google.common.io.Resources`, `ByteStreams` - `com.google.common.base.Strings` - String utilities - **Apache Commons** - `org.apache.commons.lang.SystemUtils` - Platform detection - `org.apache.commons.lang.StringUtils` - String operations - **Jackson YAML Processing** - `com.fasterxml.jackson.databind.ObjectMapper` - `com.fasterxml.jackson.dataformat.yaml.YAMLFactory` - YAML serialization for logging

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully