-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathshellscript-success.yaml
116 lines (114 loc) · 3.3 KB
/
shellscript-success.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
maximumMessageAge: skip
pipeline:
- type: processor.genericjson
- type: processor.shellscript
output: shell_json
config:
command: /bin/bash
args:
- '-c'
- |
while read line
do
echo "{ \"line\": \"$line\" }"
done
echo $STDERR_MSG > /dev/stderr
environment:
STDERR_MSG: 'Standard Error'
stdin: |+
Hello
World
# Set json to true, if output is JSON (single line)
# json: true
#
# Set jsonMultiline to true, if output is JSON (multiline)
jsonMultiline: true
#
# Set yaml to true, if output is YAML
# yaml: true
#
# Set csv to true, if output is comma separated values
# csv: true
#
# Set tsv to true, if output is tab separated values
# tsv: true
#
# Script is successful on either exit code 0 or 1, default 0
exitcodes:
- 0
- 1
- type: processor.shellscript
output: shell_yaml
config:
command: /bin/bash
args:
- '-c'
- |
while read line
do
echo $line
done
stdin: |
{{ { "hello" : "world" }|yaml_encode }}
yaml: true
- type: processor.shellscript
output: shell_csv
config:
command: /bin/bash
args:
- '-c'
- |
echo '"Hello","World","From","CSV"'
echo "Line,\"Break"
echo "Here\",In,CSV"
csv: true
- type: processor.shellscript
output: shell_tsv
config:
command: /bin/bash
args:
- '-c'
- |
echo -e "Hello\tWorld"
tsv: true
- type: output.test
config:
name: "shellscript_json"
result: "{{ shell_json }}"
strip: true
expected: |
{'parsed': [{'line': 'Hello'}, {'line': 'World'}], 'stdout': '{ "line": "Hello" }\n{ "line": "World" }\n', 'stderr': 'Standard Error\n', 'returncode': 0}
- type: output.test
config:
name: "shellscript_yaml"
result: "{{ shell_yaml }}"
strip: true
expected: |
{'parsed': {'hello': 'world'}, 'stdout': 'hello: world\n', 'stderr': '', 'returncode': 0}
- type: output.test
config:
name: "shellscript_csv"
result: "{{ shell_csv }}"
strip: true
expected: |
{'parsed': [['Hello', 'World', 'From', 'CSV'], ['Line', 'Break\nHere', 'In', 'CSV']], 'stdout': '"Hello","World","From","CSV"\nLine,"Break\nHere",In,CSV\n', 'stderr': '', 'returncode': 0}
- type: output.test
config:
name: "shellscript_tsv"
result: "{{ shell_tsv }}"
strip: true
expected: |
{'parsed': [['Hello', 'World']], 'stdout': 'Hello\tWorld\n', 'stderr': '', 'returncode': 0}