Assuming we have a PyPi
repository (simple API) created in Artifactory
. Inside of a Jenkins pipeline, it's required to use JFrog CLI
to publish any kind of artifacts because of the security policies.
Is there a way to push a python package (dist/tar.gz, wheel
) to the PyPi repo using JFrog CLI?
Yes you can.
Configure Artifactory:
> jfrog c add
Configure the project's resolution repository. You shoud set the virtual repository you created.
> jfrog rt pipc
Install project dependencies with pip from Artifactory:
> jfrog rt pipi -r requirements.txt --build-name=my-pip-build --build-number=1 --module=jfrog-python-example
Package the project, create distribution archives (tar.gz and whl):
> python setup.py sdist bdist_wheel
Upload the packages to the pypi repository in Artifactory:
> jfrog rt u dist/ pypi/ --build-name=my-pip-build --build-number=1 --module=jfrog-python-example
Collect environment variables and add them to the build info:
> jfrog rt bce my-pip-build 1
Publish the build info to Artifactory:
> jfrog rt bp my-pip-build 1
Install published package by installing it from Artifactory using pip:
> jfrog rt pip-install jfrog-python-example
Validate package successfully installed:
> pip show jfrog-python-example
More details listed in Github jfrog/project-examples.