Synced from Hive. This page is pulled from hivecommons/hive@v5 during the docs build. Edit the canonical source in the Hive repository.

Importing Tekton pipelines

Hive can read Tekton (and OpenShift Pipelines) resources and propose a lifecycle workflow model that knows how a repository builds and ships. Each Tekton pipeline becomes a pipeline (a DAG of tasks) inside the model. Hive renders the pipelines and binds them to lifecycle states; Tekton keeps running them. Hive does not create, re-run or cancel PipelineRuns.

There are two sources:

  • Files: Tekton YAML in the repository (for example a .tekton/ directory used by Pipelines-as-Code), or pasted into the API.
  • A live cluster: hive lists Tekton resources through kubectl and ingests them with the same parser.

For how this fits with the other kinds of workflow, see Workflows in hive. The GitHub Actions equivalent is Importing GitHub Actions workflows; a repository ingest reads both at once. To have hive run a DAG on its own agents instead, author it natively as a DAG workflow, or import this pipeline as a DAG workflow draft.

Import from repository files

Prerequisites

  • Owner role on the hive. Saved ingests are audited as workflow_ingest.
  • Read access to the repository for the hive’s GitHub credential, when you ingest by repository name. Pasting files needs no repository access.

Which files are read

When ingesting a repository, hive keeps:

  • every YAML file under .tekton/, tekton/, pipelines/, .pipelines/, openshift/ci/ or ci/tekton/ at the repository root;
  • other YAML files whose name suggests a pipeline and whose content looks like Tekton.

A file may hold several YAML documents or a Kubernetes List. Every document whose apiVersion is in tekton.dev, triggers.tekton.dev or pipelinesascode.tekton.dev is considered. Pasted files (API files) are read when the path ends in .yml or .yaml and the content looks like Tekton.

From the dashboard

  1. Open Settings → Workflows and choose Ingest.
  2. Pick the repository in Repository, or type it in or owner/repo.
  3. Optionally set Save as, then choose Preview or Ingest and save.

The result shows whether the model compiles, its Diagnostics and a Proposed columns diagram, with Open in editor to review it on the canvas.

With the API

POST /api/workflows/ingest is the same call as for GitHub Actions: exactly one of repo (owner/name) or files (path → contents), plus optional save and name. See Importing GitHub Actions workflows for the response fields and errors.

jq -n \
  --rawfile pipeline .tekton/build-pipeline.yaml \
  --rawfile pr .tekton/build-pull-request.yaml \
  --rawfile push .tekton/build-push.yaml \
  '{name: "example-app-tekton",
    files: {".tekton/build-pipeline.yaml": $pipeline,
            ".tekton/build-pull-request.yaml": $pr,
            ".tekton/build-push.yaml": $push}}' |
curl -s -X POST https://hive.example/api/workflows/ingest \
  -H "Authorization: Bearer $HIVE_TOKEN" \
  -H "Content-Type: application/json" \
  -d @-

Import from a live cluster

Cluster ingest reads what is installed rather than what is in a repository. Hive runs kubectl get <resource> -o json for, in order:

ResourceRequired
pipelines.tekton.devYes: without it the cluster has no Tekton and the ingest stops
tasks.tekton.devNo
pipelineruns.tekton.devNo
eventlisteners, triggertemplates, triggerbindings, triggers in triggers.tekton.devNo; when the Triggers CRDs are missing the ingest records triggers-crd-missing and continues

Each object is written to a virtual file cluster/<namespace>/<kind>/<name>.yaml (server-side fields such as managedFields, resourceVersion and uid are dropped, and status is kept on PipelineRuns only) and passed to the same Tekton parser as repository files. Citations in the model point at those virtual paths.

Prerequisites

  • Owner role on the hive.
  • kubectl on the hive’s PATH, and either a kubeconfig (KUBECONFIG or ~/.kube/config) or an in-cluster ServiceAccount token. Without them the cluster panel is disabled and the API answers 422 with the reason.
  • A context. Leave it empty to use kubectl’s current context, or name one from the kubeconfig. GET /api/workflows/ingest/capabilities lists the contexts the hive can see.
  • RBAC for the identity in that context: get and list on the resources above, in the namespace you ingest (a Role and RoleBinding), or cluster-wide for all namespaces (a ClusterRole and ClusterRoleBinding). Grant the Triggers resources too when the Triggers CRDs are installed: a missing CRD is skipped, but a denied list stops the ingest with 403.

A namespaced read-only role:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: hive-tekton-reader
  namespace: ci
rules:
  - apiGroups: ["tekton.dev"]
    resources: ["pipelines", "tasks", "pipelineruns"]
    verbs: ["get", "list"]
  - apiGroups: ["triggers.tekton.dev"]
    resources: ["eventlisteners", "triggertemplates", "triggerbindings", "triggers"]
    verbs: ["get", "list"]

From the dashboard

On Settings → Workflows → Ingest, open From a cluster under Other sources:

  • Context: a context from the list, or the current context;
  • Namespace, or All namespaces (capped at 25);
  • Label selector (optional), applied to every list;
  • Save as (optional; the default is derived from the context and namespace).

Preview or Ingest and save shows the same result block as a repository ingest plus Observed runs: the last PipelineRun per pipeline and its status.

With the API

POST /api/workflows/ingest/cluster:

FieldTypeMeaning
contextstringKubeconfig context; empty uses the current context
namespacestringNamespace to read; required unless allNamespaces is set
allNamespacesbooleanRead every namespace, capped at 25
selectorstringLabel selector applied to every list
runsPerPipelineintegerNewest PipelineRuns kept per pipeline (default 3, at most 20)
repositorystring, owner/nameRepository the model is scoped to; defaults to one derived from the context and namespace
savebooleanStore the result at the next free version
namestringModel name
curl -s -X POST https://hive.example/api/workflows/ingest/cluster \
  -H "Authorization: Bearer $HIVE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"context": "ci-cluster", "namespace": "ci",
       "repository": "example-org/example-app", "save": true}'

The response has the same fields as a repository ingest (model, compiled, diagnostics, profile, files, pipelines, entry) plus:

  • source: cluster:<context>/<namespace> (current-context and * stand in for an empty context and all namespaces);
  • runs[]: the last observed run per pipeline, as {pipeline, namespace, run, status, completed}, where status is Succeeded, Running, Unknown or the Tekton reason (Failed, Cancelled, …);
  • namespaces[]: the namespaces read.

Errors:

StatusCause
400No namespace and no allNamespaces
403RBAC denied a list
404The context is not in the kubeconfig
413A cap was exceeded: more than 500 objects after run trimming, or more than 8 MiB of YAML
422Tekton is not installed (no pipelines.tekton.dev), or the hive has no kubectl or kubeconfig

Each kubectl call times out after 60 seconds.

Runs are observations

PipelineRuns never become lifecycle states. The last run per pipeline is returned in runs[], recorded on the model as an annotation workflow.hivecommons.dev/observed-run/<pipeline id>, and listed as an observed-run-status finding, so a reviewer can see “this pipeline last succeeded” without the model inferring anything from it. Older runs beyond runsPerPipeline are dropped and reported as runs-trimmed.

How Tekton maps into the model

A Pipeline resource, or a PipelineRun with an embedded pipelineSpec, becomes one entry in spec.pipelines:

TektonModel field
file pathpath; the id is tkn- plus a slug of the path, with the resource name added when one file holds several pipelines
metadata.name (or generateName without the trailing -)name
each entry of spec.tasksa node, kind: task
each entry of spec.finallya node, kind: finally, that needs every task
runAfterthe node’s needs: these are the DAG’s edges
$(tasks.<name>.…) references in params, when, workspaces or matrixextra needs, since Tekton orders those tasks too
taskRef.name, a resolver reference, or an inline taskSpecref (the name; <resolver>:<name, url or pathInRepo>; or inline)
when expressionswhen, as <input> <operator> [values] or cel: <expression>
matrixmatrix summary (parameter names, include count, dynamic)

A runAfter that names no task is dropped and reported as runafter-unresolved; an edge that would close a cycle is dropped and reported as runafter-cycle.

Triggers and roles

A Tekton Pipeline has no trigger of its own. Ingest finds triggers in:

  • Pipelines-as-Code annotations on a PipelineRun that embeds the pipeline or references it by name: pipelinesascode.tekton.dev/on-event, on-target-branch, on-path-change, and the pipelinesascode.tekton.dev/event-type label. An on-cel-expression is recorded as a cel trigger; when it contains event == "pull_request" or event == "push", that event is added as well.
  • Tekton Triggers: a TriggerTemplate whose resource template is a PipelineRun naming the pipeline adds a webhook trigger.

The role then decides where the pipeline binds:

TriggersRoleWhere it binds
any pull_requestpr-verifyEvery state in the CI / Review column
push to a tag-looking branch (refs/tags/... or a v* pattern)releaseA Release column after Merged
pushpush-verifyA Main CI column after Merged
incomingmanualListed, not bound to a state
anything else, including only webhookotherListed, not bound to a state

A pipeline used by both pull-request and push runs binds to CI / Review and to Main CI. A pipeline with no trigger in the ingested files is reported as no-trigger and binds to no state: a bare Pipeline library file needs the PipelineRuns that use it in the same ingest. On a cluster, that means runs created by Pipelines-as-Code (which carry its annotations) or a TriggerTemplate.

Other findings you may see: task-definitions (Task, ClusterTask, StepAction or TaskRun documents, which are not pipelines), tekton-triggers (Triggers resources are noted, not modelled), pipelineref-external (a PipelineRun names a pipeline not in the ingested files), finally, taskref-bundle (deprecated bundle references), custom-task, on-error, pipeline-resources and duplicate-task.

What is and is not executed

Done by
Creating and running PipelineRuns, TaskRuns, workspaces, resultsTekton (and Pipelines-as-Code or Tekton Triggers), unchanged
Reading Tekton definitions and building the DAGHive, at ingest time only
Reporting the last run per pipelineHive, at cluster ingest time only, as an annotation
Deriving an item’s lifecycle stateHive, from facts it observes (checks, reviews, labels), once the model is bound and derivation is on
Moving merged PRs through Main CI and ReleaseNot yet: live derivation reports pipeline.status as unknown for Tekton pipelines, so these columns render but stay empty

Where Pipelines-as-Code reports pull-request runs back to GitHub as checks, hive’s CI / Review derivation sees them the way it sees any other check on the pull request’s head.

How it shows in the dashboard

The same places as a GitHub Actions ingest: the Ingest view’s result block (plus Observed runs for a cluster), the Library and model detail with the diagram, citations and raw JSON, the editor, and, once bound on Settings → Repos, the Activity Monitor’s columns.

Worked example

.tekton/build-pipeline.yaml clones, runs unit tests and lint in parallel, builds an image, and always reports:

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: build
spec:
  tasks:
    - name: clone
      taskRef:
        name: git-clone
    - name: unit-test
      runAfter: [clone]
      taskRef:
        name: go-test
    - name: lint
      runAfter: [clone]
      taskRef:
        name: golangci-lint
    - name: build-image
      runAfter: [unit-test, lint]
      taskRef:
        name: buildah
      params:
        - name: CONTEXT
          value: $(tasks.clone.results.path)
  finally:
    - name: report
      taskRef:
        name: report-status

.tekton/build-pull-request.yaml and .tekton/build-push.yaml are the Pipelines-as-Code runs that use it:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: build-on-pull-request
  annotations:
    pipelinesascode.tekton.dev/on-event: "[pull_request]"
    pipelinesascode.tekton.dev/on-target-branch: "[main]"
spec:
  pipelineRef:
    name: build
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: build-on-push
  annotations:
    pipelinesascode.tekton.dev/on-event: "[push]"
    pipelinesascode.tekton.dev/on-target-branch: "[main]"
spec:
  pipelineRef:
    name: build

Ingesting the three files gives one pipeline with four levels. build-image needs clone as well as its runAfter entries, because its params read clone’s result; report is a finally node that needs every task.

{
  "id": "tkn-tekton-build-pipeline",
  "name": "build",
  "system": "tekton",
  "path": ".tekton/build-pipeline.yaml",
  "role": "pr-verify",
  "triggers": [
    { "event": "pull_request", "branches": ["main"] },
    { "event": "push", "branches": ["main"] }
  ],
  "nodes": [
    { "id": "clone", "name": "clone", "kind": "task", "ref": "git-clone", "level": 0 },
    { "id": "unit-test", "name": "unit-test", "kind": "task", "needs": ["clone"], "ref": "go-test", "level": 1 },
    { "id": "lint", "name": "lint", "kind": "task", "needs": ["clone"], "ref": "golangci-lint", "level": 1 },
    { "id": "build-image", "name": "build-image", "kind": "task", "needs": ["clone", "lint", "unit-test"], "ref": "buildah", "level": 2 },
    { "id": "report", "name": "report", "kind": "finally", "needs": ["clone", "unit-test", "lint", "build-image"], "ref": "report-status", "level": 3 }
  ],
  "levels": 4
}

The pull_request run makes the pipeline pr-verify, so it is bound to every CI / Review state with a citation to .tekton/build-pipeline.yaml. The push run also binds it to a Main CI column after Merged, followed by Done:

[
  { "id": "main-ci", "label": "Main CI", "hint": "Runs after merge: tkn-tekton-build-pipeline", "states": ["main-ci"] },
  { "id": "done", "label": "Done", "hint": "Every post-merge pipeline has run", "states": ["done"], "terminal": true }
]

spec.meta.source is tekton, and spec.coverage.findings carries one finally warning for the pipeline file. Ingesting the same Pipeline from a cluster gives the same DAG, with paths such as cluster/ci/pipeline/build.yaml.

Import as a task workflow draft

A Tekton Pipeline, or a PipelineRun with an embedded pipelineSpec, can also be converted into a DAG workflow (task workflow) draft, with the same call, limits and guarantees as for GitHub Actions: see Import as a task workflow draft. The draft has no agents, prompts, schedule or notification target, is stored only disabled, and nothing in the files is executed or fetched (no task, no resolver, no bundle).

jq -n --rawfile p .tekton/build-pipeline.yaml \
  '{files: {".tekton/build-pipeline.yaml": $p}, system: "tekton", pipeline: "build"}' |
curl -s -X POST https://hive.example/api/task-workflows/import \
  -H "Authorization: Bearer $HIVE_TOKEN" \
  -H "Content-Type: application/json" \
  -d @-

What maps

TektonTask workflow draft
each entry of spec.tasks, then spec.finallya step with the task’s name (sanitised)
runAfter, and $(tasks.<name>.…) references in params, when, workspaces or matrixdepends_on
a finally taska step that depends on every other step (see finally-not-guaranteed below)
retries: Nretry.max_attempts: N+1, at most 10
timeout:the step’s timeout, kept within 1m to 24h
spec.params (string)spec.params; a param with no default is required

What does not map

Findings have the same shape as for GitHub Actions. Tekton-specific codes:

CodeConstructWhat the draft does instead
finally-not-guaranteedfinallyThe step runs only if every other step succeeded; Tekton runs it whatever the outcome. Task workflows have no “run after completion” dependency
when-expressionwhenThe step runs whenever its dependencies succeed
resultspipeline results, and a task reading $(tasks.<name>.results.<r>)The ordering is kept; the value is not. Use {{steps.<id>.result}} in the prompt
workspacespipeline and task workspacesSteps share nothing but their reported results
matrixmatrixOne step, run once
on-erroronErrorNothing; set on_failure on the step
remote-task-refa resolver or bundle taskRefNoted; it is not fetched
custom-taska taskRef to a non-Tekton apiVersionNothing
step-commands-not-carriedthe task’s taskRef or inline taskSpec stepsNothing; write the step’s prompt
secret-referencesecretKeyRef, secretRef and secret workspace bindings, in the pipeline and in the file’s PipelineRuns and TasksNothing; the finding carries <secret:NAME>
secret-resourcea Secret document in the fileSkipped; its values are not carried
secret-default-droppeda param whose name or default looks like a credentialThe default is not carried; the param becomes required
param-typean array or object paramA text param without the default
dependency-droppeda runAfter to an unknown task, a cycle, a duplicate taskThe edge or task is dropped
triggers-not-carriedPipelines-as-Code annotations and Tekton Triggers that start the pipelineNothing; add spec.schedule or start runs from the API
run-params-not-carrieda PipelineRun’s params valuesNothing; pass them when starting a run
tekton-triggers, pipeline-resources, task-definitions, pipelineref-externalTriggers resources, PipelineResources, Task documents, a PipelineRun naming a pipeline not in the filesReported per file; not carried
retries, timeoutretries of 10 or more, a timeout outside 1m to 24hCapped or moved into the range
incomplete-sourcea task whose definition could not be matchedIts settings were not checked

The GitHub Actions guide lists the codes both systems share (id-renamed, param-renamed, param-default-clipped, file-level findings and limits).

Next steps

  • Review the draft in the editor, confirm the inferred states, then bind it on Settings → Repos.
  • Use Simulate on the model’s detail page to check where real issues and PRs would land.
  • To hand states to agents, add agent grants; see Workflow models and Agent configuration.
  • To have hive run the same DAG on its own agents, import it as a task workflow draft and complete it, or author it natively as a DAG workflow.