【问题标题】:parse user credentials from yaml file into the shell script将 yaml 文件中的用户凭据解析到 shell 脚本中
【发布时间】:2019-02-26 21:53:25
【问题描述】:

我必须将 Bugzilla 帐户的用户凭据从 yaml 文件解析到触发 Jenkins 作业的 shell 脚本中。

---
- name: 'USER_BUGZILLA'
  valueFrom:
    secretKeyRef:
        name: 'bugzilla_bot'
        key: 'user'

- name: 'PASSWORD_BUGZILLA'
  valueFrom:
    secretKeyRef:
        name: 'bugzilla_bot'
        key: 'password'
谁能建议我如何解决这个用例?

【问题讨论】:

    标签: shell parsing jenkins passwords yaml


    【解决方案1】:

    假设您的 yaml 文件名为“foo.yaml”

    read -r user password <<<$(grep key foo.yaml | sed "s/^.[^']*'//" | sed "s/'.*$//")
    

    $user 将保存用户名
    $password 将保存密码

    【讨论】:

    • 太棒了!!!,去掉这个后,我需要使用 $user 和 $password 作为 bugzilla login 登录到 bugzilla,提示 Bugzilla username: $user 和 Bugzilla Password: $password;这些值需要在没有用户交互的情况下在 shell 脚本中传递,因为该脚本将由 Jenkins 作业运行
    • 你不能通过 --username=USERNAME 和 --password=PASSWORD 传递用户名和密码吗? - manpages.debian.org/testing/bugzilla-cli/bugzilla.1.en.html
    • 我尝试了 bugzilla login --username myuser --password mypswd ,它再次提示我bugzilla login --username myuser --password myuser usage: bugzilla [-h] [--bugzilla BUGZILLA] [--nosslverify] [--cert CERT] [--login] [--username USERNAME] [--password PASSWORD] [--ensure-logged-in] [--no-cache-credentials] [--cookiefile COOKIEFILE] [--tokenfile TOKENFILE] [--verbose] [--debug] [--version] {new,query,info,modify,attach,login} ... bugzilla: error: unrecognized arguments: --username --password myuser
    • 终于可以登录了,谢谢
    • 酷,如果对您有帮助,请将答案标记为正确。
    猜你喜欢
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2016-06-21
    • 1970-01-01
    • 2022-12-17
    • 2012-07-10
    相关资源
    最近更新 更多