python - 如何在 gitlab-ci.yaml 中使用变量文件/服务帐户文件
问题描述
我在 gitlab repo 中设置了包含 GCP 服务帐户 json 的变量文件。参考图片:
我需要服务帐户才能访问 BQ 以进行我的一项单元测试。如何在 gitlab-ci.yaml 中使用这个 SA?
这是我的一部分gitlab-ci
:
.test-template:
image: python:3.7
cache:
key: ${CI_COMMIT_REF_NAME}
paths: # specify paths to be cached
- .cache/pip
- venv/
environment:
name: dev
before_script:
- # Maybe add in here
- echo ${API_TOKEN}
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
- cd tests/
only:
refs:
- master
- dev
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
pre-test:
stage: test
extends: .test-template
script:
# - export ENV=local
# - pip install -r ./requirements.txt
- pytest pre_test.py -v
解决方案
推荐阅读
- html - 如何使所有内容出现在下拉菜单中?
- python - 如何阅读动态参数气流运算符?
- node.js - 我如何捕获和处理错误:EEXIST:文件已存在,在nodejs中复制文件“somepath”“anotherpath”
- python - 使用 statsmodels 进行线性回归
- javascript - 无法从中获取 getTotalLength()
- python - py-spy:如何运行具有依赖项的脚本?
- c# - 当我打开使用 openXML 创建的 xlsx 文件时如何修复错误:“修复的记录:/xl/workbook.xml 中的工作表属性?
- javascript - 如何在函数中使用 keyup 函数?
- java - Play framework 2.7.* Java - HTTP Context Deprecated - Token Based Authentication
- php - in_array 语句的问题