Parse local files and export specified property paths as environment variables with designated names.
Property paths reference lodash.get
File formats can be .json, .yml, .yaml
Other formats are processed as plain text, which doesn't support deep paths (not recommended)
The principle is to output
##[set-output key=value], allowingCloud Native Buildto parse it into corresponding environment variables. This will be exposed in build logs and is not suitable for handling sensitive information.
File path
Mapping relationship between property paths in the file and exported environment variable names
Each line of text represents a mapping: key_in_file:key_to_export
Example:
prop1:key1 prop2.sub3:key2 prop4.sub5[1].name:key3
Parse file content with this encoding
# .cnb.yml
main:
push:
- stages:
- name: export env from file
image: cnbcool/data-from-file
settings:
file: env.yml
keys: |
prop1:key1
prop2.sub3:key2
prop4.sub5[1].name:key3
exports:
key1: KEY_1
key2: KEY_2
key3: KEY_3
- name: show
script: echo "$KEY_1 $KEY_2 $KEY_3"
# env.yml
prop1: value1
prop2:
sub3: value2
prop4:
sub5:
- name: tom cat
age: 18
- name: jerry mouse
age: 24