0
votes

I have a python package I want to test and build using Jenkins and tox. However, it depends on a package in our private artifactory. Although poetry picks up on it correctly, the moment tox kicks in (and uses pip over poetry to install dependencies), it can't find the package.

My poetry lock file has

reference = "snakepit"
type = "legacy"
url = "https://our private artifactory

My Jenkinsfile sets up POETRY_HTTP_BASIC_PYPI_USERNAME and POETRY_HTTP_BASIC_PYPI_PASSWORD which allows poetry to install without the url in the lock file having my credentials.

After some searching it seemed like I needed to extend legacy_tox_ini in the pyproject.toml. This now looks like:

legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py36,py37,py38

indexserver =
    default = https://pypi.python.org/simple
    ourartifactory = https://{env:POETRY_HTTP_BASIC_PYPI_USERNAME}:{env:POETRY_HTTP_BASIC_PYPI_PASSWORD}@our artifactory url


[testenv]
deps =
    pytest
    pytest-cov

setenv =
    SOME_ENV={env:SOME_ENV}

commands =
    pytest tests

I also tested adding :ourartifactory:problempackage to deps here, but it doesn't help either.

How can I make pip recognize the private artifactory in this setting?

1

1 Answers

0
votes

In the end the whole indexserver and deps was unnecessary, and a simple

envVar(key: 'PIP_CONFIG_FILE', value: "/pypi-artifactory/pip.conf")

in the Jenkinsfile sufficed. Of course this requires your docker image to have the correct pip.conf.