我想引用私有(private) git 存储库中的依赖项,它通常在 pyproject.toml
中看起来像这样:
[tool.poetry.dependencies]
...
my-module = { git = "https://username:password@gitlab.com/something", branch = "branch" }
我的问题是如何通过环境变量或我可以在 CICD 中使用的任何其他方式注入(inject)密码。 AFAIK 诗歌不支持环境变量,因此如果您遇到相同的情况,基本上是在寻找解决方法。
最佳答案
您可以设置 ssh key 以在没有密码的情况下使用 gitlab 进行身份验证,
并将您的 git url 从 https 更改为 ssh。
为此,生成 id_rsa
, 和 id_rsa.pub
文件,
把它们放进 ~/.ssh
,
并使用 git remote add origin git@gitlab.com:gitlab-org/gitlab.git
更新您的远程位置
可以在这里阅读更多详细信息:https://docs.gitlab.com/ee/ssh/
关于python - 如何将 secret 传递给诗歌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62632313/