【问题标题】:How to declare values in .yaml file Environment Variables and Call it in Jenkins如何在 .yaml 文件环境变量中声明值并在 Jenkins 中调用它
【发布时间】:2019-11-30 15:22:43
【问题描述】:

我有一个 config.yaml 文件,用于在为 Robot Framework 开发时存储所有数据库和 API 密钥凭据。

我必须将 config.yaml 放在 Jenkins 工作区中并将路径传递给命令行以覆盖。

robot --variablefile <jenkins workspace path>/config.yaml test1.robot

下面是 config.yaml 文件:

db_mysql:
    DB_USER: '**********'
    DB_HOST: '**********'
    DB_PWD: '***********'
    DB_NAME: '**********'
    DB_PORT: '**********'

db2_mysql:
    DB2_USER: '*********'
    DB2_HOST: '**********'
    DB2_PWD: '*************'
    DB2_NAME: '**************'
    DB2_PORT: '*************'

api_key:
    APIkey: '****************'

base_url:
    BASE_URL: '***************'

如何将所有值声明为环境变量并将其与 Jenkins 环境变量相关联?

另外,我有三个环境:

  1. 本地

  2. 分期和

  3. 生产

如果它是本地的,如何提供或传递分别从 Jenkins 为暂存和生产选择本地凭据?

【问题讨论】:

    标签: python jenkins robotframework


    【解决方案1】:

    您可以使用函数“readYaml”将所有文件分配给变量

    def datas = readYaml text: """
    something: 'my datas'
    size: 3
    isEmpty: false
    """
            assert datas.something == 'my datas'
            assert datas.size == 3
            assert datas.isEmpty == false
    

    (见here

    问候

    【讨论】:

      猜你喜欢
      • 2021-04-26
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 2021-12-07
      • 2021-05-24
      • 2018-06-26
      • 2019-12-26
      • 1970-01-01
      相关资源
      最近更新 更多