Pipeline: Tekton's Results don't get trimmed

Created on 14 Jul 2020  Â·  1Comment  Â·  Source: tektoncd/pipeline

Expected Behavior

Tekton's Results have the line feeds.
Some error occurs when we want to pass parameters directly from the results, for example Kaniko.

Actual Behavior

Tekton's Results have no line feeds.

Example Test Codes

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: openshift-handson-line-feed-results
  namespace: handson-example
spec:
  tasks:
    - name: get-result
      taskSpec:
        steps:
          - name: set-results
            image: goreleaser/goreleaser # any images which have the shell
            script: |
              echo "123" > /tekton/results/pre
              echo "abc" > /tekton/results/post
        results:
        - name: pre
        - name: post
    - name: checkresults
      runAfter: ["get-result"]
      taskSpec:
        params:
          - name: IMAGETAG
        steps:
          - name: check-params
            image: goreleaser/goreleaser 
            script: |
              echo $(params.IMAGETAG)
      params:
        - name: IMAGETAG
          value: "$(tasks.get-result.results.pre):v$(tasks.get-result.results.post)-1.0"

and the console displays the follow:

$tkn pipelinerun logs openshift-handson-line-feed-results-run-7tsxl -f -n handson-example
[get-result : set-results] + echo 123
[get-result : set-results] + echo abc

[checkresults : check-params] + echo 123
[checkresults : check-params] + :vabc
[checkresults : check-params] 123
[checkresults : check-params] /tekton/scripts/script-0-q89sn: line 4: :vabc: not found

Example Usage Codes

    - name: push-container
      taskRef:
        name: kaniko
      workspaces:
        - name: source
          workspace: local-source
      runAfter: ["int-test", "gen-report"]
      params:
        - name: DOCKERFILE
          value: src/main/docker/Dockerfile.jvm
        - name: IMAGE
          value: "$(params.image-registry):v$(tasks.get-versions.results.version2)hhh" #this
````

and the console displays the follow:

```shell
[build-and-push] error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: getting tag for destination: tag can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ`: v2
[build-and-push] hhh

Additional Info

  • OpenShift version:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0-4-g38212b5", GitCommit:"4a4cd759b616cdba344dd73386727c10d3d2dde1", GitTreeState:"clean", BuildDate:"2020-05-25T22:39:54Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.1+f63db30", GitCommit:"f63db30", GitTreeState:"clean", BuildDate:"2020-05-25T22:57:30Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}

$ oc version
Client Version: 4.4.6
Server Version: 4.4.6
Kubernetes Version: v1.17.1+f63db30
  • Tekton Pipeline version:
$ tkn version
Client version: 0.10.0
Pipeline version: v0.11.3
Triggers version: v0.4.0
kinbug

Most helpful comment

Thanks for the issue report! It's true that Tekton doesn't perform any kind of string trimming for results. This has been intentional since we didn't want to make assumptions related to the content that task authors can put into results. But we should document this.

If you're writing a bash script then to prevent a newline being inserted into a result when using echo you can use echo -n. Other tool and shell behaviours will vary but you can typically omit a newline in some way from the content you're writing to result files.

>All comments

Thanks for the issue report! It's true that Tekton doesn't perform any kind of string trimming for results. This has been intentional since we didn't want to make assumptions related to the content that task authors can put into results. But we should document this.

If you're writing a bash script then to prevent a newline being inserted into a result when using echo you can use echo -n. Other tool and shell behaviours will vary but you can typically omit a newline in some way from the content you're writing to result files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vdemeester picture vdemeester  Â·  3Comments

chmouel picture chmouel  Â·  3Comments

nader-ziada picture nader-ziada  Â·  4Comments

csantanapr picture csantanapr  Â·  3Comments

silverlyra picture silverlyra  Â·  4Comments