logo
0
1
WeChat Login

data-from-file

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], allowing Cloud Native Build to parse it into corresponding environment variables. This will be exposed in build logs and is not suitable for handling sensitive information.

Parameters

file

  • type: String
  • required: Yes

File path

keys

  • type: String
  • required: Yes

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

encoding

  • type: String
  • required: No
  • default: utf8

Parse file content with this encoding

Usage in Cloud Native Build

# .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

About

读取解析文件内数据并导出 支持深层属性 支持yaml、json和plain text

508.00 KiB
0 forks1 stars1 branches0 TagREADMEMIT license
Language
Markdown56%
JavaScript33%
License6.9%
Dockerfile3.1%
Others1%