Rakesh
Rakesh

Reputation: 4127

How to put any file in artifactory using python?

I have a requirement where any file should be put in the artifact using python language. I tried to search all over internet but I couldn't find any help.

Please share code snippet or something which can help me to achieve this.

Any help is greatly appreciated here.

Upvotes: 3

Views: 18078

Answers (4)

grant_sytniak
grant_sytniak

Reputation: 1

"pyartifactory" provides the REST API functionality you are looking for.

"pyartifactory" is an alternative to "artifactory". It differs by providing more concise methods.

pyartifactory: https://pypi.org/project/pyartifactory/

Their provided "Download an artifact" example:

artifact = art.artifacts.download("<ARTIFACT_PATH_IN_ARTIFACTORY>", "<LOCAL_DIRECTORY_PATH>")
# artifact = art.artifacts.download("my-artifactory-repository/my/new/artifact/file.txt", "Desktop/my/local/directory")
# The artifact location is returned by the download method
# If you have not set a <LOCAL_DIRECTORY_PATH>, the artifact will be downloaded in the current directory

Upvotes: 0

Niranjan
Niranjan

Reputation: 106

Artifactory python module can be used to upload artifacts into artifactory. https://pypi.python.org/pypi/artifactory/0.1.17

Here is an example from the website used to upload a file into artifactory:

from artifactory import ArtifactoryPath
path = ArtifactoryPath("http://my-artifactory/artifactory/libs-snapshotlocal/myapp/1.0")
path.mkdir()

path.deploy_file('./myapp-1.0.tar.gz')

Upvotes: 8

James Carpenter
James Carpenter

Reputation: 129

The defend against fruit project provides the integration with Artifactory and Python you are looking for. http://teamfruit.github.io/defend_against_fruit/

Upvotes: 4

mhawke
mhawke

Reputation: 87084

Artifactory exposes a REST API. Here's a link to the documentation. See the section on "Deploy Artifact".

Basically you will need to build a REST client. There might already exist one for Artifactory? If you need to write it yourself there is a WADL file that might make things easier (see also wadllib).

Upvotes: 4

Related Questions