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

TriggerBinding doesn't support multiline string param? #772

Closed
gejunqiang opened this issue Sep 28, 2020 · 3 comments
Closed

TriggerBinding doesn't support multiline string param? #772

gejunqiang opened this issue Sep 28, 2020 · 3 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@gejunqiang
Copy link

gejunqiang commented Sep 28, 2020

Problem Description

I want to trigger my TaskRun dynamically with Tekton Triggers. And in TriggerBinding, I use a param named dockerfile, and the value is a constant multiline string, it's shown as follows:

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
  name: poc-taskbinding
  namespace: poc
spec:
  params:
    - name: gitrevision
      value: $(body.git.revision)
    - name: gitrepositoryurl
      value: $(body.git.ssh_url)
    - name: imageurl
      value: $(body.image.url)
    - name: imagetag
      value: $(body.image.tag)
    - name: dockerfile
      value: |
        FROM alpine:3.9
        ADD artifacts.tar.gz /artifacts/

Then I use this command to call the event listener:

curl -v -X POST poc-trigger.gjq.netease.com -d '
{
  "git": {
    "revision": "master",
    "ssh_url": "git@github.com:gejunqiang/test-deploy-javawebapp.git"
  },
  "image":{
    "url": "hub.c.163.com/gejunqiang/poc-javawebapp",
    "tag": "v1"
  }
}'

But it doesn't work. And the event listener pod logs messages with a level: error, the logs are shown as below:

{"level":"info","logger":"eventlistener","caller":"sink/sink.go:181","msg":"ResolvedParams : [{Name:gitrepositoryurl Value:git@github.com:gejunqiang/test-deploy-javawebapp.git} {Name:imageurl Value:hub.c.163.com/gejunqiang/poc-javawebapp} {Name:imagetag Value:v1} {Name:dockerfile Value:FROM alpine:3.9\nADD artifacts.tar.gz /artifacts/\n} {Name:gitrevision Value:master}]","knative.dev/controller":"eventlistener","/triggers-eventid":"njg45","/trigger":""}
{"level":"error","logger":"eventlistener","caller":"sink/sink.go:266","msg":"problem creating obj: &errors.errorString{s:\"couldn't unmarshal json: invalid character '\\\\n' in string literal\"}","knative.dev/controller":"eventlistener","/triggers-eventid":"njg45","/trigger":"","stacktrace":"github.com/tektoncd/triggers/pkg/sink.Sink.CreateResources\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:266\ngithub.com/tektoncd/triggers/pkg/sink.Sink.processTrigger\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:183\ngithub.com/tektoncd/triggers/pkg/sink.Sink.HandleEvent.func1\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:94"}
{"level":"error","logger":"eventlistener","caller":"sink/sink.go:184","msg":"couldn't unmarshal json: invalid character '\\n' in string literal","knative.dev/controller":"eventlistener","/triggers-eventid":"njg45","/trigger":"","stacktrace":"github.com/tektoncd/triggers/pkg/sink.Sink.processTrigger\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:184\ngithub.com/tektoncd/triggers/pkg/sink.Sink.HandleEvent.func1\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:94"}

From the first line of logs, we can see that the TriggerBinding resolved params correctly. Then it caused an error: &errors.errorString{s:\"couldn't unmarshal json: invalid character '\\\\n' in string literal\"}". I guess maybe it's the problem with newline character in multiline string, Or maybe the way I use the TriggerBinding is wrong. Can someone give me some suggestions.

Additional Info

The version of Tekton Triggers: v0.8.1

@dibyom dibyom added the kind/bug Categorizes issue or PR as related to a bug. label Sep 28, 2020
@dibyom
Copy link
Member

dibyom commented Sep 29, 2020

The error location looks very similar to #777

@dibyom
Copy link
Member

dibyom commented Dec 9, 2020

This should have been fixed with #823
Please feel free to reopen if this is still an issue!
/close

@tekton-robot
Copy link

@dibyom: Closing this issue.

In response to this:

This should have been fixed with #823
Please feel free to reopen if this is still an issue!
/close

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.

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

3 participants