-
Notifications
You must be signed in to change notification settings - Fork 81
Support slashes (/) in GitHub branch names #320
Description
Is your feature request related to a problem? Please describe.
While trying out KAM, I hit an issue when using slashes (/) a GitHub branch name, in combination with the Tekton EventListener and Pipelines. In particular the "clone-source" task in "app-ci-pipeline" failed, due to the fact it was given the incorrect GitHub ref:
{"level":"error","ts":1656509135.6855068,"caller":"git/git.go:55","msg":"Error running git [fetch --recurse-submodules=yes --depth=1 origin --update-head-ok --force feat]: exit status 128\nfatal: couldn't find remote ref feat\n","stacktrace":"github.com/tektoncd/pipeline/pkg/git.run\n\t/opt/app-root/src/go/src/github.com/tektoncd/pipeline/pkg/git/git.go:55\ngithub.com/tektoncd/pipeline/pkg/git.Fetch\n\t/opt/app-root/src/go/src/github.com/tektoncd/pipeline/pkg/git/git.go:150\nmain.main\n\t/opt/app-root/src/go/src/github.com/tektoncd/pipeline/cmd/git-init/main.go:53\nruntime.main\n\t/usr/lib/golang/src/runtime/proc.go:225"}
{"level":"fatal","ts":1656509135.6874197,"caller":"git-init/main.go:54","msg":"Error fetching git repository: failed to fetch [feat]: exit status 128","stacktrace":"main.main\n\t/opt/app-root/src/go/src/github.com/tektoncd/pipeline/cmd/git-init/main.go:54\nruntime.main\n\t/usr/lib/golang/src/runtime/proc.go:225"}
As you can see, the "ref" is set to feat, where my actual branchname is feat/gitops-cicd-run-2.
I tracked it down to the CEL filter in the EventListener config, which is configured to filter the GitHub ref coming from the GitHub Webhook post request body as such:
- name: overlays
value:
- expression: 'body.ref.split(''/'')[2]'
key: ref
This expression seems to split the ref field of the webhook request body bashed on slashes, and grab the third element, which in my case is feat and not feat/gitops-cicd-run-2 (the ref field that my GitHub webhooks sends for this branch is: "ref": "refs/heads/feat/gitops-cicd-run-2"). This results in a problem in the clone-source Task not being able to clone from the correct GitHub ref.
I searched a bit, and noticed that this filter is actually described in the Tekton documentation. So I'm wondering if I'm doing something wrong, or that I'm indeed correct that this Tekton pipeline definition does not support slashes (/) in branch names.
Describe the solution you'd like
Be able to use slashes (/) in GitHub branches.
Describe alternatives you've considered
The alternative is obviously to not use slashes (/) in my branch names. But since this is somewhat of a recommended way of working (using slashes or dashed in Git branches), this should simply work ootb IMO.