Use the Kaniko action to build images based upon a Dockerfile, then publish the image to a Docker registry. Kaniko builds images inside a container or Kubernetes cluster. This action also reports the image and tag names to the workflow run for artifact traceability purposes. View build artifact information in the workflow and artifacts in .
Automatic artifact data reporting
This action reports artifact-related data to the workflow run for artifact traceability purposes.
Do not include the CloudBees action: Register a build artifact for the same artifact version, as the resulting run would register duplicate artifact entries to CloudBees platform.
Prerequisites
To authenticate with the Docker registry, you must have a Docker config file in the ${HOME}/.docker/config.json path.
Use the OCI credentials configuration action to generate a Docker config file, as in the following example.
In your YAML file, add:
- id: dockerconfig name: Configure container registry credentials uses: cloudbees-io/configure-oci-credentials@v1 with: registry: ${{ vars.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }}
The generated Docker configuration file is formatted in JSON.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The locations of the target images to be published. Formatted as a comma-separated list for passing multiple images. |
|
String |
No |
The build arguments to be passed to the Kaniko build. Formatted as a comma-separated list for passing multiple build arguments. |
|
String |
No |
The path to the build context.
Default is |
|
String |
No |
The path to the Dockerfile.
Default is |
|
String |
No |
The label metadata added to the final image. Formatted as a comma-separated list for passing multiple labels. |
|
String |
No |
Registry mirrors to use for loading images. Formatted as a comma-separated list for passing multiple registries. |
|
Boolean |
No |
If set to |
|
String |
No |
Specify a target stage to build when using a multi-stage Dockerfile. |
|
String |
No |
Full path location where the image is to be saved, including the filename. To use this option, the image file must be in the TAR format. |
|
String |
No |
The verbosity of logging when running the Kaniko build.
Accepted inputs are: |
|
String |
No |
The commit ID from the source repository, used when registering the build artifact in CloudBees platform.
Default is |
|
String |
No |
The clone URL of the source repository, used when registering the build artifact in CloudBees platform.
Default is |
|
String |
No |
The ref or branch of the source repository, used when registering the build artifact in CloudBees platform.
Default is |
Output
| Output name | Data type | Description |
|---|---|---|
|
JSON string |
The unique identifiers for each of the published image locations ( |
|
String |
The image digest. |
|
String |
Image reference of the first specified destination and the image digest, in a format not part of the OCI standard but supported by most container tools. Tools loading such an image reference ignore the tag, which serves as a hint for humans, but perform the lookup based on the image repository and digest only. Use this image reference format to guarantee that the same image is used even if the tag has been overwritten, and to prevent stale image caches on different nodes. |
|
String |
The tag of the first pushed image. |
|
String |
The tag of the first specified destination and the image digest, in a format not part of the OCI standard but supported by most container tools. Tools loading such an image reference ignore the tag, which serves as a hint for humans, but perform the lookup based on the image repository and digest only. Use this format to guarantee that the same image is used even if the tag has been overwritten, and to prevent stale image caches on different nodes. |
Usage examples
Basic example
The following is a basic usage example for this action:
- name: Build a container image with Kaniko uses: cloudbees-io/kaniko@v1 with: destination: path/to/registry/host/my-image:1.0.1,path/to/registry/host/my-image:latest
Using optional inputs
The following example specifies optional inputs:
- name: Kaniko build with optional inputs uses: cloudbees-io/kaniko@v1 with: destination: path/to/registry/host/my-image:1.0.1,path/to/registry/host/my-image:latest build-args: BUILDKIT_CONTEXT_KEEP_GIT_DIR=1,BUILDKIT_INLINE_CACHE=1 context: . dockerfile: path/to/Dockerfile labels: maintainer=John Smith,version=1.0.1 tar-path: path/to/image.tar verbosity: warn
Using the action output
Access the artifact-ids values in downstream steps using the outputs context.
The following is the JSON format for the artifact-ids output, where <destination> is the specified destination input parameter value, and <artifact-version-id> is the unique identifier of the artifact version.
{ "<destination>": "<artifact-version-id>" }
The following is an example of an artifact-ids JSON for two artifact IDs:
{ "index.docker.io/example/my-docker:1.0.87": "1234abcd-56ef-gh78-9012-ijklmnop3456", "index.docker.io/example/my-docker:1.0.87-dev": "ab34cd12-78gh-56ef-ij78-3456mnopkl90" }
Use the artifact-ids output as follows, where <action_step_ID> is the action step ID, and <destination_URL> is the destination URL:
-
${{ steps.<action_step_ID>.outputs.artifact-ids }}for a JSON string of all outputted artifact ID values. -
${{ fromJSON(steps.<action_step_ID>.outputs.artifact-ids).<destination_URL> }}for a single artifact ID value.