将 yaml 文件中的用户凭据解析到 shell 脚本中
parse user credentials from yaml file into the shell script
我必须将 Bugzilla 帐户的用户凭据从 yaml 文件解析到触发 Jenkins 作业的 shell 脚本中。
---
- name: 'USER_BUGZILLA'
valueFrom:
secretKeyRef:
name: 'bugzilla_bot'
key: 'user'
- name: 'PASSWORD_BUGZILLA'
valueFrom:
secretKeyRef:
name: 'bugzilla_bot'
key: 'password'
谁能建议我如何解决这个用例?
假设您的 yaml 文件名为 "foo.yaml"
read -r user password <<<$(grep key foo.yaml | sed "s/^.[^']*'//" | sed "s/'.*$//")
$user 将保留用户名
$password 将保存密码
我必须将 Bugzilla 帐户的用户凭据从 yaml 文件解析到触发 Jenkins 作业的 shell 脚本中。
---
- name: 'USER_BUGZILLA'
valueFrom:
secretKeyRef:
name: 'bugzilla_bot'
key: 'user'
- name: 'PASSWORD_BUGZILLA'
valueFrom:
secretKeyRef:
name: 'bugzilla_bot'
key: 'password'
假设您的 yaml 文件名为 "foo.yaml"
read -r user password <<<$(grep key foo.yaml | sed "s/^.[^']*'//" | sed "s/'.*$//")
$user 将保留用户名
$password 将保存密码