You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the triggers, you can submit `BuildRun` instances when certain events happen. The idea is to be able to trigger Shipwright builds in an event driven fashion, for that purpose you can watch certain types of events.
609
+
610
+
**Note**: triggers rely on the [Shipwright Triggers](https://github.com/shipwright-io/triggers) project to be deployed and configured in the same Kubernetes cluster where you run Shipwright Build. If it is not set up, the triggers defined in a Build are ignored.
611
+
612
+
The types of events under watch are defined on the `.spec.trigger` attribute, please consider the following example:
Certain types of events will use attributes defined on `.spec.source` to complete the information needed in order to dispatch events.
628
+
629
+
#### GitHub
630
+
631
+
The GitHub type is meant to react upon events coming from GitHub WebHook interface, the events are compared against the existing `Build` resources, and therefore it can identify the `Build` objects based on `.spec.source.url` combined with the attributes on `.spec.trigger.when[].github`.
632
+
633
+
To identify a given `Build` object, the first criteria is the repository URL, and then the branch name listed on the GitHub event payload must also match. Following the criteria:
634
+
635
+
- First, the branch name is checked against the `.spec.trigger.when[].github.branches` entries
636
+
- If the `.spec.trigger.when[].github.branches` is empty, the branch name is compared against `.spec.source.revision`
637
+
- If `spec.source.revision` is empty, the default revision name is used ("main")
638
+
639
+
The following snippet shows a configuration machting `Push` and `PullRequest` events on the `main` branch, for example:
In order to watch over images, in combination with the [Image](https://github.com/shipwright-io/image) controller, you can trigger new builds when those container image names change.
661
+
662
+
For instance, lets imagine the image named `ghcr.io/some/base-image` is used as input for the Build process and every time it changes we would like to trigger a new build. Please consider the following snippet:
663
+
664
+
```yaml
665
+
# [...]
666
+
spec:
667
+
trigger:
668
+
when:
669
+
- name: watching for the base-image changes
670
+
type: Image
671
+
image:
672
+
names:
673
+
- ghcr.io/some/base-image:latest
674
+
```
675
+
676
+
#### Tekton Pipeline
677
+
678
+
Shipwright can also be used in combination with [Tekton Pipeline](https://github.com/tektoncd/pipeline), you can configure the Build to watch for `Pipeline` resources in Kubernetes reacting when the object reaches the desired status (`.objectRef.status`), and is identified either by its name (`.objectRef.name`) or a label selector (`.objectRef.selector`). The example below uses the label selector approach:
679
+
680
+
```yaml
681
+
# [...]
682
+
spec:
683
+
trigger:
684
+
when:
685
+
- name: watching over for the Tekton Pipeline
686
+
type: Pipeline
687
+
objectRef:
688
+
status:
689
+
- Succeeded
690
+
selector:
691
+
label: value
692
+
```
693
+
694
+
While the next snippet uses the object name for identification:
695
+
696
+
```yaml
697
+
# [...]
698
+
spec:
699
+
trigger:
700
+
when:
701
+
- name: watching over for the Tekton Pipeline
702
+
type: Pipeline
703
+
objectRef:
704
+
status:
705
+
- Succeeded
706
+
name: tekton-pipeline-name
707
+
```
708
+
605
709
### Sources
606
710
607
711
Sources represent remote artifacts, as in external entities added to the build context before the actual Build starts. Therefore, you may employ `.spec.sources` to download artifacts from external repositories.
0 commit comments