2

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Alex
  • 798
  • 1
  • 8
  • 21

1 Answers1

2

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.

vijay v
  • 1,888
  • 1
  • 12
  • 19
  • Do you need to pip install through the `jf` command or can pip install regular and just use `jf` for uploading packages and build info? – red888 Jan 11 '23 at 16:17
  • I just opened an SO post about this. Doing the upload will cause Jfrog to nest the package under a folder named "dist" on the server which doesn't make sense: https://stackoverflow.com/questions/75087181/jfrog-cli-is-nesting-pypi-packages-under-the-name-of-the-local-folder-when-uploa – red888 Jan 11 '23 at 17:55