Skip to content
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

Question : gitlab interceptor / triggerbinding variable interpolation #361

Closed
DanielBFox opened this issue Jan 20, 2020 · 5 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@DanielBFox
Copy link

Expected Behavior

Be able to access HTTP JSON body parameters of Gitlab push hook event

Actual Behavior

I try to access the ref parameter from the body of a Gitlab push hook event
But I receive this error message from the event listener pod :
{"level":"error","logger":"eventlistener","caller":"sink/sink.go:144","msg":"failed to ApplyEventValuesToParams: &{%!w(string=failed to replace JSONPath value for param gitrevision: {string $(body.ref) []}: &{%!w(string=ref is not found)})}","knative.dev/controller":"eventlistener","/triggers-eventid":"f7rh6","/trigger":"trigger-gitlab","stacktrace":"github.com/tektoncd/triggers/pkg/sink.Sink.processTrigger\n\t/workspace/go/src/github.com/tektoncd/triggers/pkg/sink/sink.go:144\ngithub.com/tektoncd/triggers/pkg/sink.Sink.HandleEvent.func1\n\t/workspace/go/src/github.com/tektoncd/triggers/pkg/sink/sink.go:93"}

Steps to Reproduce the Problem

Gitlab push hook
Request headers:
Content-Type: application/json
X-Gitlab-Event: Push Hook
X-Gitlab-Token: ...
Request body:
{
"object_kind": "push",
"event_name": "push",
"before": "8d910b6b871c270f63548a84f51c486f67015084",
"after": "b5266fdec6473cb223fd146987c0e238dd5eed86",
"ref": "refs/heads/master",
"checkout_sha": "b5266fdec6473cb223fd146987c0e238dd5eed86",
"message": null,
...

TriggerBinding interceptor
"
apiVersion: tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: ci
namespace: staging-mycalculator
spec:
params:
- name: gitrevision
value: $(body.ref)
- name: gitrepositoryurl
value: $(body.repository.git_ssh_url)
- name: gitrepositoryname
value: $(body.repository.name)


apiVersion: tekton.dev/v1alpha1
kind: EventListener
metadata:
name: listener
namespace: staging-mycalculator
spec:
serviceAccountName: staging
triggers:
- name: trigger-gitlab
interceptors:
- gitlab:
eventTypes:
- Push Hook
bindings:
- name: ci
template:
name: ci
"

Additional Info

I installed the latest releases of triggers and pipelines

@aitchjoe
Copy link

Same problem!

I also tried CEL/Github/WebHook interceptors, the result is even worse:

panic: runtime error: invalid memory address or nil pointer dereference

and the eventlistenersink pod crashed.

@aitchjoe
Copy link

aitchjoe commented Jan 21, 2020

I tried $(body) and it is null. But from gitlab_test.go:

		{
			name: "valid event",
			GitLab: &triggersv1.GitLabInterceptor{
				EventTypes: []string{"foo", "bar"},
			},
			args: args{
				eventType: "foo",
				payload:   []byte("somepayload"),
			},
			wantErr: false,
			want:    []byte("somepayload"),
		},

this test confirm payload/body is not null, so I think the problem maybe within sink.go.

@dibyom
Copy link
Member

dibyom commented Jan 27, 2020

I think this might be related to #357

Does this still happen with the 0.2.1 preview build? https://github.com/tektoncd/triggers/releases/tag/v0.2.1-preview

@dibyom
Copy link
Member

dibyom commented Jan 27, 2020

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 27, 2020
@DanielBFox
Copy link
Author

Hello,

I just tried with the release v0.2.1 and it works now like a charm.

{"level":"info","logger":"eventlistener","caller":"sink/sink.go:147","msg":"params: %+v[{gitrepositoryurl {string git@gitlab.com:danielbfoxg/mycalculator/go/add.git []}} {gitrepositoryname {string add []}} {gitrevision {string refs/heads/master []}}]","knative.dev/controller":"eventlistener","/triggers-eventid":"dlfgs","/trigger":"trigger-gitlab"}

Thanks for the great job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants