如何将秘密传递给诗歌

时间:2020-06-29 06:20:14

标签: python python-poetry

我想引用私有git存储库中的依赖项,通常在pyproject.toml中看起来像这样:

[tool.poetry.dependencies]
...
my-module = { git = "https://username:password@gitlab.com/something", branch = "branch" }

我的问题是如何通过环境变量或可在CICD中使用的任何其他方式注入密码。 AFAIK诗歌不支持环境变量,因此,如果您遇到过相同的情况,则基本上可以寻找解决方法。

1 个答案:

答案 0 :(得分:0)

您可以设置ssh密钥以使用gitlab进行身份验证,而无需输入密码,
并将您的git网址从https更改为ssh。

为此,生成id_rsaid_rsa.pub文件,
将它们放在~/.ssh中,
并使用git remote add origin git@gitlab.com:gitlab-org/gitlab.git

更新您的远程位置

可以在此处阅读更多详细信息:https://docs.gitlab.com/ee/ssh/