Skip to content

Conversation

sbose78
Copy link
Member

@sbose78 sbose78 commented Oct 25, 2021

This is an experiment to see if we can automatically setup everything needed for a Build[Run] to be triggered from a Git[Hub] event. This proof-of-concept should work with Github & Gitlab at the most.

Relevant commit

6daa1be

Demo

https://youtu.be/uaBlgTlw1wo

Summary of the flow:

  • Upon creation of a Build resource, the controller sets up an TriggerTemplate and an EventListener automatically without any input in the API.
  • When a webhook event gets trigger, the EventListener as per the TriggerTemplate triggers creation of a TaskRun that creates a branch-specific Shipwright Build & BuildRun such that the image for branch foo gets pushed into tag foo.

Summary of changes:

  • Ship a ClusterTriggerBinding which "exposes" the branch and the revision information from an event.
  • Ship a ClusterTask for creation of Shipwright Builds/BuildRuns which would be referenced from controller-generated TriggerTemplate per `Build.
  • Upon creation of Build, create a TriggerTemplate & EventListener.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2021

@sbose78: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 25, 2021
@openshift-ci openshift-ci bot requested review from imjasonh and otaviof October 25, 2021 16:35
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from sbose78 after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

type: string
steps:
- image: >-
image-registry.openshift-image-registry.svc:5000/openshift/cli:$(params.VERSION)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with the kubectl Task from TektonHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we could use the cli, or maybe create a specialized application (like for instance the waiter, mutate-image, etc).

// ClusterTriggerBinding "shipwright-executor" will need
// to be shipped as part of the Shipwright installation.
Ref: "shipwright-executor",
Kind: triggersapi.ClusterTriggerBindingKind,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ship this.

// creates the appropriate BuildRun ( and Build, since embedded buildSpec is not
// supported in BuildRuns yet ).
TaskRef: &taskrunapi.TaskRef{
Name: "shipwright-executor",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ship this.

apiVersion: triggers.tekton.dev/v1alpha1
kind: ClusterTriggerBinding
metadata:
name: shipwright-executor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Github/Gitlab specific.

@imjasonh
Copy link
Contributor

When a webhook event gets trigger, the EventListener as per the TriggerTemplate triggers creation of a TaskRun that creates a branch-specific Shipwright Build & BuildRun such that the image for branch foo gets pushed into tag foo.

Ideally, this would create a Custom Task Run that creates a BuildRun, correct? I think we can get by with creating TaskRuns that create BuildRuns, but I wouldn't want this to be our long-term solution, since it wastes Pod resources.

@sbose78
Copy link
Member Author

sbose78 commented Oct 25, 2021

Correct.

I was mostly checking to see how far we'd get without that. I'm not a fan of two pods per event either 🤦‍♂️

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 26, 2021

@sbose78: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 26, 2021
@adambkaplan
Copy link
Member

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 23, 2022
@SaschaSchwarze0
Copy link
Member

This scenario will be implemented in https://github.com/shipwright-io/triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants