-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hooks into Pipeline Lifecycle #1460
Comments
Can you motivate this a bit more with a concrete example? What workflow is unnecessarily hard to describe today, that this makes better? Maybe include an outline of a Pipeline YAML before + after this change. |
Couple of related ideas:
One fear: i dont want us to end up in a scenario like apache we end up with many many different kinds of hooks such as |
I have something like the following in mind for a possible example: apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: pull-request-pipeline
spec:
params:
- name: repositoryUrl
description: The url of the GitHub repository
- name: revision
description: The revision of the repository
- name: pullRequestUrl
description: The url of the pull request
- name: secretName
description: The secret to be used to authenticate against GitHub
- name: secretKey
description: The key with the secret (specified by secretName) that stores the authentication information for GitHub
beforeAll:
steps:
- name: pull-request-set-status
image: github.com/tektoncd/pipeline/cmd/pullrequest-init
command:
- /ko-app/pullrequest-init
env:
- name: GITHUBTOKEN
valueFrom:
secretKeyRef:
name: $(params.secretName)
key: $(params.secretKey)
args:
- -url
- $(params.pullRequestUrl)
- -path
- /workspace2
- -mode
- download
afterAll:
steps:
- name: pull-request-set-status
image: github.com/tektoncd/pipeline/cmd/pullrequest-init
command:
- /ko-app/pullrequest-init
env:
- name: GITHUBTOKEN
valueFrom:
secretKeyRef:
name: $(params.secretName)
key: $(params.secretKey)
args:
- -url
- $(params.pullRequestUrl)
- -path
- /workspace2
- -mode
- upload
tasks:
# This task will clone the repository to some volume that will be reused by the next steps
- name: git-clone-repo
taskRef:
name: git-clone
params:
- name: repositoryUrl
value: $(params.repositoryUrl)
- name: revision
value: $(params.revision)
- name: build-repo
runAfter:
- git-clone-repo
taskRef:
name: go-build-repo
- name: lint-repo
runAfter:
- git-clone-repo
taskRef:
name: go-lint-repo
- name: test-repo
runAfter:
- build-repo
taskRef:
name: go-test-repo To add an additional "notification" step, you would just have to add another What this does is allows the apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: go-lint-repo
spec:
volumes:
- name: clone-dir
persistentVolumeClaim:
claimName: host-path-pvc
steps:
- image: golang # contains bash
script: |
#!/usr/bin/env bash
go build /repo
volumeMounts:
- mountPath: /repo
name: clone-dir The above example takes the implementation/approach of making unique |
@imjasonh Since #1438 is still ongoing, I didn't want to get too into the weeds with the volume stuff in any particular way. The pull request hooks aren't really providing much value/information in this example, but conceptually, each |
With consideration for individual Yet another alternative could be for apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: slack-notify
spec:
steps:
- $(injection)
- image: slack-image # contains bash
script: |
#!/usr/bin/env bash
# slack stuff One issue here is that this |
@afrittoli What are your thoughts on this? I saw the notifications design document, but not sure the direction this work has gone on in. |
/kind feature |
I've opened #2082 to track emitting events during execution, that feels to me like it would be enough to resolve this issue, but before I close it, what do other folks think? |
Yeah agreed - I think we've decomposed this larger idea into a number of smaller issues including the new event emitting one. I think it's safe to close. |
Rotten issues close after 30d of inactivity. /close Send feedback to tektoncd/plumbing. |
@tekton-robot: Closing this issue. In response to this:
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. |
Expected Behavior
Tekton
Pipeline
s have hooks into the execution of tasks. This way, an additional system/resource is not needed to monitor the internal status. Put another way,Task
s do not need to concern themselves with updating an external system about their results.Actual Behavior
Currently, there is no way for
Task
s to report their results unless done so explicitly within a step. This makes what should be "composable" units more specified.PipelineResources
address this in some capacity by allowing steps to be prepended/appended toTask
(a hook of sorts), but fall short because their execution is a contract that constricts theTask
and are highly specified, which will not address all use cases. Instead, expose abefore
/after
orbeforeAll
/afterAll
field in thePipelineSpec
(the internals of this tag would be analogous to a step). With this shift of responsibility, thePipeline
becomes the more specified unit that can internally resolve the generalTask
lifecycle.Regarding implementation, the
PipelineRun
could create uniqueTaskRun
to resolve this lifecycle or the steps could be injected (as current withPipelineResources
), where this could be to the benefit of data locality. To summarize and clarify, thePipeline
would explicitly define the "injection" behavior and it would be implicit to theTask
.As an example, a Pipeline can have a
beforeAll
/afterAll
hook on multipleTask
where each of these is a CI/CD step that will have a corresponding status in a pull request. This ties nicely with the recent addition of 9873614 so that users can simply specify aTask
that is a script and easily add it to aPipeline
definition to improve their CI/CD experience.The text was updated successfully, but these errors were encountered: