How to pass secrets to poetry

Viewed 1409

I want to reference a dependency in a private git repository which normally would look like this in the pyproject.toml:

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

My question is how can I inject the password through environment variables or any other way I can use in my CICD. AFAIK poetry doesn't support environment variables, so basically looking for a workaround if you've been in the same situation.

1 Answers

you can set up ssh keys to authenticate with gitlab without a password,
and change your git url from https to ssh.

to do that, generate id_rsa, and id_rsa.pub files,
put them in ~/.ssh,
and update your remote location with git remote add origin git@gitlab.com:gitlab-org/gitlab.git

can read more details here: https://docs.gitlab.com/ee/ssh/

Related