A PipelineRun in Tekton failed because a TaskRun within it didn’t complete successfully, and the system couldn’t proceed to the next stage.
This usually means the TaskRun itself encountered an error in one of its steps, or a prerequisite Task or PipelineResource wasn’t available.
Common Causes and Fixes:
-
Step Failure within a Task:
- Diagnosis: Check the logs for the
TaskRunthat failed. The error message will be in the output of one of thestepsdefined in theTask.
Look for non-zero exit codes in thekubectl logs <failed-taskrun-name> -c <step-container-name> -n tekton-resultsstepoutput. - Fix: Modify the
Taskdefinition to correct the command or script that failed. For example, if akubectl applycommand failed due to an invalid resource, fix the YAML in your Git repository and update theTaskto point to the corrected source.# Example: Correcting a Docker build command steps: - name: build-image image: gcr.io/cloud-builders/docker script: | #!/usr/bin/env bash docker build -t my-repo/my-image:latest . # Ensure the tag is valid and the registry is accessible. - Why it works: Tekton executes the
stepsas containers. If a container exits with a non-zero status, theTaskRunfails. Fixing the underlying command or script resolves the exit code.
- Diagnosis: Check the logs for the
-
Missing or Incorrect
PipelineResource:- Diagnosis: If your
Taskdepends onPipelineResources(like Git repositories or container images), ensure they are correctly defined and accessible. Check theTaskRunevents for errors related to fetching resources.
Look for messages like "failed to clone repository" or "image not found."kubectl describe taskrun <failed-taskrun-name> -n tekton-results - Fix: Verify the
urlorimagefields in yourPipelineResourcedefinition are correct, and that the service account used by Tekton has permissions to access private repositories or registries.# Example: Correcting a GitPipelineResource apiVersion: tekton.dev/v1alpha1 kind: PipelineResource metadata: name: my-git-repo spec: type: git params: - name: url value: "https://github.com/my-org/my-project.git" # Corrected URL - name: revision value: "main" - Why it works:
PipelineResourcesare how Tekton fetches external dependencies. If these are misconfigured, theTaskcannot get the necessary input, leading to failure.
- Diagnosis: If your
-
Service Account Permissions:
- Diagnosis: If your
Tasksteps need to interact with Kubernetes resources (e.g.,kubectl apply,kubectl get), theServiceAccountassociated with theTaskRunmight lack the necessary RBAC permissions. Check theTaskRunlogs for "permission denied" or "forbidden" errors.kubectl logs <failed-taskrun-name> -c <step-container-name> -n tekton-results - Fix: Grant the required permissions to the
ServiceAccountused by theTaskRunviaRoleandRoleBinding(orClusterRoleandClusterRoleBinding).# Example: Granting 'create' permission on 'deployments' apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: tekton-pipeline-deploy-binding namespace: tekton-results subjects: - kind: ServiceAccount name: default # The ServiceAccount your TaskRun uses namespace: tekton-results roleRef: kind: Role name: deployment-manager # A Role that grants 'create' on 'deployments' apiGroup: rbac.authorization.k8s.io - Why it works: Kubernetes enforces access control through RBAC. The
ServiceAccountacts as the identity for the pod running yourTasksteps, and it needs explicit permissions to perform actions on cluster resources.
- Diagnosis: If your
-
Incorrect
imagein aStep:- Diagnosis: If a
stepuses animagethat doesn’t exist or is misspelled, the container will fail to start. Check theTaskRunevents or the pod logs for "ErrImagePull" or "ImagePullBackOff."kubectl describe pod <taskrun-pod-name> -n tekton-results - Fix: Correct the
imagename in theTaskdefinition to a valid and accessible container image.# Example: Correcting an image name steps: - name: check-version image: ubuntu:20.04 # Corrected image tag script: echo "Running on Ubuntu $(lsb_release -sr)" - Why it works: The container runtime cannot pull an image that doesn’t exist or is specified incorrectly, preventing the step from executing.
- Diagnosis: If a
-
Missing
ResultsDefinition inTask:- Diagnosis: If a
Taskdefinesresultsthat aPipelineexpects, but theTaskdefinition itself doesn’t correctly output them (e.g., missingresultssection or incorrectpath), thePipelineRuncan fail. Look for errors indicating missing results in thePipelineRunevents.kubectl describe pipelinerun <failed-pipelinerun-name> -n tekton-results - Fix: Ensure the
Taskcorrectly declares itsresultsand that thestepswrite to the specifiedpathwithin theTask’sresultsdirectory.# Example: Task definition with results apiVersion: tekton.dev/v1alpha1 kind: Task metadata: name: build-and-tag spec: results: - name: image-digest description: Digest of the built image path: $(results.image-digest.path) # Path to write the digest steps: - name: build image: gcr.io/cloud-builders/docker script: | docker build -t my-image:latest . docker push my-image:latest DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' my-image:latest) echo "$DIGEST" > $(results.image-digest.path) # Writing to the declared path - Why it works: Tekton uses
resultsto pass information betweenTasksin aPipeline. If aTaskfails to produce an expected result, thePipelinecannot proceed.
- Diagnosis: If a
-
Volume Mount Issues:
- Diagnosis: If a
Taskrelies on persistent storage or shared volumes, and these are not correctly configured or mounted, steps might fail due to missing files or directories. Check pod logs for "No such file or directory" errors.kubectl logs <failed-taskrun-name> -c <step-container-name> -n tekton-results - Fix: Ensure
volumesare defined in theTaskorPipelineand correctly mounted in the relevantsteps. If usingPersistentVolumeClaims, verify they are bound and available.# Example: Mounting a volume for shared workspace apiVersion: tekton.dev/v1alpha1 kind: Task metadata: name: process-files spec: steps: - name: process image: ubuntu volumeMounts: - name: shared-data mountPath: /data volumes: - name: shared-data emptyDir: {} # Or a PVC - Why it works: Steps need access to the filesystem to read input or write output. Incorrect volume configuration means the necessary directories or files won’t be present.
- Diagnosis: If a
The next error you’ll likely encounter after fixing these is a PipelineRun failure due to a different TaskRun failing, or a TaskRun failing for a reason not covered above, such as a resource quota being exceeded in the namespace.