Search code examples
tektontekton-pipelines

Trigger pipeline from another pipeline in Tekton


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!


Solution

  • 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.