Skip to content

trigger_comment may screw pipelinerun yaml with the the newline #1929

@chmouel

Description

@chmouel

when we have a yaml with the {{trigger_comment}} expansion variable we may end up with bad yaml:

for example this pipelinerun:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: prow-commands
  annotations:
    pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/openshift-pipelines/pac-boussole/main/pipeline-boussole.yaml"
    pipelinesascode.tekton.dev/on-comment: "^/(hello|merge|help|lgtm|(assign|unassign|label|unlabel)[ ].*)$"
    pipelinesascode.tekton.dev/max-keep-runs: "2"
spec:
  params:
    - name: trigger_comment
      value: |
        {{ trigger_comment }}
    - name: repo_owner
      value: "{{ repo_owner }}"
    - name: repo_name
      value: "{{ repo_name }}"
    - name: pull_request_number
      value: "{{ pull_request_number }}"
    - name: pull_request_sender
      value: "{{ body.issue.user.login }}"
    - name: git_auth_secret
      value: "{{ git_auth_secret }}"
    - name: comment_sender
      value: "{{ sender }}"
  pipelineRef:
    name: boussole

if i do a github comment with newlines like this

/help

it will be expanded to this:

Image

and then we get a parser error:

Image

because it's not a yaml anymore..

I suggest we change the trigger_comment to expand the \r\n to real \n the same way we do for pull_requests_labels:

https://pipelinesascode.com/docs/guide/matchingevents/#matching-pipelinerun-to-a-pull-request-labels

and let the user do it from their script... since there is no reliable way to do this and this is prone to bad user input interpolation

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions