Image resource
An Image resource represents an image in a remote repository. It is
usually used as an output for Tasks
that build images. This allows the Tasks
to push to any registry.
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: example-resources-image
namespace: default
spec:
type: image
params:
- name: URL
value: gcr.io/staging-images/example
The parameters that can be added are the following:
-
URL
: The complete path to the image, including the registry and the image tag. -
digest
: The image digest uniquely identifies a particular build of an image with a tag.
Surfacing the image digest built in a task
To surface the image digest in the output of the TaskRun
the builder tool should produce this information in an OCI Image specification index.json
file. This file should be placed on a location as specified in the task definition under the resource outputImageDir
. Annotations in index.json
are ignored, and if there are multiple versions of the image, the latest isused.
The build-push task defines the outputImageDir
for the builtImage
resource in /workspace/buildImage
:
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-push
spec:
inputs:
resources:
- name: workspace
type: git
outputs:
resources:
- name: builtImage
type: image
outputImageDir: /workspace/builtImage
steps: ...
If no value is specified for |
TaskRun
includes the image digest in the resourcesResult
field and is part of the TaskRun.Status
. For example:
status:
...
resourcesResult:
- digest: sha256:eed29cd0b6feeb1a92bc3c4f977fd203c63b376a638731c88cacefe3adb1c660
name: example-image-web
...
If the index.json
file is not produced, the image digest will not be included in the TaskRun
output.