1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/builds-identifying-image-change-triggers.adoc

100 lines
4.4 KiB
Plaintext

// Module included in the following assemblies:
//
// * builds/triggering-builds-build-hooks.adoc
:_mod-docs-content-type: PROCEDURE
[id="builds-image-change-trigger-identification_{context}"]
= Identifying the image change trigger of a build
As a developer, if you have image change triggers, you can identify which image change initiated the last build. This can be useful for debugging or troubleshooting builds.
.Example `BuildConfig`
[source,yaml]
----
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: bc-ict-example
namespace: bc-ict-example-namespace
spec:
# ...
triggers:
- imageChange:
from:
kind: ImageStreamTag
name: input:latest
namespace: bc-ict-example-namespace
- imageChange:
from:
kind: ImageStreamTag
name: input2:latest
namespace: bc-ict-example-namespace
type: ImageChange
status:
imageChangeTriggers:
- from:
name: input:latest
namespace: bc-ict-example-namespace
lastTriggerTime: "2021-06-30T13:47:53Z"
lastTriggeredImageID: image-registry.openshift-image-registry.svc:5000/bc-ict-example-namespace/input@sha256:0f88ffbeb9d25525720bfa3524cb1bf0908b7f791057cf1acfae917b11266a69
- from:
name: input2:latest
namespace: bc-ict-example-namespace
lastTriggeredImageID: image-registry.openshift-image-registry.svc:5000/bc-ict-example-namespace/input2@sha256:0f88ffbeb9d25525720bfa3524cb2ce0908b7f791057cf1acfae917b11266a69
lastVersion: 1
----
[NOTE]
====
This example omits elements that are not related to image change triggers.
====
.Prerequisites
* You have configured multiple image change triggers. These triggers have triggered one or more builds.
.Procedure
. In the `BuildConfig` CR, in `status.imageChangeTriggers`, identify the `lastTriggerTime` that has the latest timestamp.
+
This `ImageChangeTriggerStatus`
Then you use the `name` and `namespace` from that build to find the corresponding image change trigger in `buildConfig.spec.triggers`.
. Under `imageChangeTriggers`, compare timestamps to identify the latest
.Image change triggers
In your build configuration, `buildConfig.spec.triggers` is an array of build trigger policies, `BuildTriggerPolicy`.
Each `BuildTriggerPolicy` has a `type` field and set of pointers fields. Each pointer field corresponds to one of the allowed values for the `type` field. As such, you can only set `BuildTriggerPolicy` to only one pointer field.
For image change triggers, the value of `type` is `ImageChange`. Then, the `imageChange` field is the pointer to an `ImageChangeTrigger` object, which has the following fields:
* `lastTriggeredImageID`: This field, which is not shown in the example, is deprecated in {product-title} 4.8 and will be ignored in a future release. It contains the resolved image reference for the `ImageStreamTag` when the last build was triggered from this `BuildConfig`.
* `paused`: You can use this field, which is not shown in the example, to temporarily disable this particular image change trigger.
* `from`: Use this field to reference the `ImageStreamTag` that drives this image change trigger. Its type is the core Kubernetes type, `OwnerReference`.
The `from` field has the following fields of note:
* `kind`: For image change triggers, the only supported value is `ImageStreamTag`.
* `namespace`: Use this field to specify the namespace of the `ImageStreamTag`.
* `name`: Use this field to specify the `ImageStreamTag`.
.Image change trigger status
In your build configuration, `buildConfig.status.imageChangeTriggers` is an array of `ImageChangeTriggerStatus` elements. Each `ImageChangeTriggerStatus` element includes the `from`, `lastTriggeredImageID`, and `lastTriggerTime` elements shown in the preceding example.
The `ImageChangeTriggerStatus` that has the most recent `lastTriggerTime` triggered the most recent build. You use its `name` and `namespace` to identify the image change trigger in `buildConfig.spec.triggers` that triggered the build.
The `lastTriggerTime` with the most recent timestamp signifies the `ImageChangeTriggerStatus` of the last build. This `ImageChangeTriggerStatus` has the same `name` and `namespace` as the image change trigger in `buildConfig.spec.triggers` that triggered the build.
[role="_additional-resources"]
.Additional resources
* link:http://docs.docker.com/v1.7/reference/api/hub_registry_spec/#docker-registry-1-0[v1 container registries]