3

I have 2 Tekton Pipelines A and B. I want to trigger execution of pipeline B when pipeline A completes.

My current workaround is to have Task in the end of pipeline A which sends REST request to Tekton's EventListener (which is already part of my system, because pipeline A builds code from GitLab, so it listens GitLab events). So I'm just masking my request as if it was from GitLab and pipeline B triggered.

I wonder if here is better way to do that? I'm aware of Pipeline inside pipeline feature, but it seems like steps from one pipeline will be included into another which is not what I want.

Thanks in advance!

Sergey Prokofiev
  • 1,815
  • 1
  • 12
  • 21

1 Answers1

5

Your current solution is correct, as Tekton indeed doesn't really offers any easy way to trigger one pipeline from another.

EventListeners are a nice way to get it working, without requiring you to authenticate against Kubernetes itself. Could be triggered with some curl/wget/any scripting language offering with http requests.

Another way to do this would be to use a Task running some tkn pipeline start command. May be more exhaustive than your current EventListener (address all params directly, setup custom workspaces easily, ... leverage options you may not want to expose through an Ingress). Requires authentication against your Kubernetes API, but no workaround mocking GitLab/GitHub/... webhook. Sample tkn-cli task can be found in Tekton Hub.

SYN
  • 4,476
  • 1
  • 20
  • 22
  • thanks a lot for your feedback. I'll wait for a while and if no one will show other significant opinion will mark you answer accepted. For now +1. – Sergey Prokofiev May 29 '22 at 20:33
  • This definitely works. However, you'll have to use `--use-param-defaults` to start the `Pipeline` with its default parameters. You will also have to specify the workspace, e.g. `-w name=my-pvc,claimName=pvc1` (from tkn pipeline start --help). – Doug Dec 01 '22 at 20:51