Tekton's Results have the line feeds.
Some error occurs when we want to pass parameters directly from the results, for example Kaniko.
Tekton's Results have no line feeds.
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
- 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
$ 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
$ tkn version
Client version: 0.10.0
Pipeline version: v0.11.3
Triggers version: v0.4.0
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.
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
echoyou can useecho -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.