How to put any file in artifactory using python?
Asked Answered
B

4

3

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.

Bray answered 17/7, 2012 at 0:58 Comment(3)
Do you mean that you need to upload artifacts into Artifactory using a Python client?Karbala
Translate this to python: curl -X PUT --data-binary @absolute_path/ivy.xml -u deployer:password -i your_host/artifactory/ext-releases-local2/org/apache/ant/…Impugn
I'm looking for the same thing. what was your solution?Speculative
S
8

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')
Sanctum answered 18/10, 2016 at 19:54 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewNina
@JamesK added an example, incase the link becomes invalidSanctum
V
4

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).

Vesting answered 17/7, 2012 at 2:0 Comment(0)
H
4

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

Harmonist answered 18/5, 2013 at 16:48 Comment(1)
While I do really like the approach taken by DefendAgainstFruit, it seems that is has two big problems: seems to be able to deploy only python modules. Second issue is not related to the question: is that it does supports only Artifactory on the output side, as it would be nice it would be able to deploy to other similar solutions.Menfolk
E
0

"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
Ehrman answered 13/7, 2023 at 20:3 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Autarky

© 2022 - 2024 — McMap. All rights reserved.