Package: do-artifactory
do_artifactoryIntroduction"do_artifactory" is an Artifactory API that makes the common artifact operations really easy to do with just a few lines of code.https://pypi.org/project/do-artifactory/MAINTAINERS:- Daniel Oberti (obertidaniel@gmail.com)Install this packageUsing a distribuible package:This project is deployed as a python package.
Once cloned we advice to install it with pip.
In order to do that the user needs to open a command prompt, go into the directory containing the project and execute the next command:gitclone<REPO># creating the dist. packagecd<REPO>
pythonsetup.pysdist# install the dist. package (located on folder "dist")pipinstall<PACKAGE.tar.gz>Using git + pipgitclone<REPO>
pipinstall-e<PACKAGE>Using pypiHow to - uploading to pypi# install the required toolspython-mpipinstall-Upipsetuptoolstwine
pythonsetup.pybdist_wheel# (publicar en pypi)python-mtwineuploaddist/*--skip-existingHow to - install from pypi# install the package anywhere:pipinstall<PACKAGE>Uninstall this packagepipuninstall<PACKAGE>Getting startedUsage:Using the environment:# Set your Linux environment as shown below or use an yaml file:setenvARTIF_URLhttps://<YOURSERVER>/artifactory/
setenvARTIF_REPO<ARTIF_REPO>
setenvARTIF_USER<ARTIF_USER>
setenvARTIF_PASS<ARTIF_PASS>#(Recomandation: use a token, never the admin password)Using a config.yml:VERBOSE_LEVEL:0ARTIF_URL:https://<YOURSERVER>/artifactory/ARTIF_REPO:<ARTIF_REPO>ARTIF_USER:<ARTIF_USER>ARTIF_PASS:<ARTIF_PASS>Importing it on your python script:fromdo_artifactoryimportDoArtifactoryarti=DoArtifactory(config='config.yml')Methods and examples:Upload files# upload "filename.txt" to an specific "target_path"arti.upload("filename.txt",target_path="arti_folder/example/")Download file/folder as a compressed file# Download "dirB" as "download.zip"arti.download(_path_source="dirA/dirB",_repo="project_A")# Download "file.txt" as "download.zip"arti.download(_path_source="dirA/dirB/file.txt",_repo="project_A")List releasesBased on the idea you are using the next dir structure:<REPOSITORY>/
        release/
            <VERSION1>/
                <RELEASE-FILE1>
                <RELEASE-FILE2>
            <VERSION2>/
                <RELEASE-FILE3># Get a list with the releases versions of "project_A"arti.list_releases(_repo="project_A")Download a release# Download the specific release "v0.0.1" from "project_A"arti.download_release(_repo="project_A",version="v0.0.1")# Download the latest release from "project_A"arti.download_release(_repo="project_A")Show file/s on an specific path and navigate a repositoryThere are a list of methods that allow you to show the list of files into the "current_path""current_path" starts as default on the root path ("."), but you can change it by using the next methods:# set the current path to another onearti.set_current_path(path="dir_A/dir_B")# get the current patharti.get_current_path()Using the last two methods in combination with the next methods, it allows you to navigate the artifactory repositories and use some filters if needed.The method search, allows you to get an artifacts_list based on the "current_path", for example:# Get the artifacts (files + folders) from "project_A" on the "current_path"arti.search(_repo="project_A")# Get the artifacts (folders) from "project_A" on the "current_path"# _type options are: (file/folder/any)arti.search(_repo="project_A",_type='folder')# Get the artifacts (folders) from "project_A" on the "current_path", but showing only the coincidence with "DirB"arti.search(_name="DirB",_repo="project_A",_type='folder')# Get the list of fullpaths from the rootarti.get_list_path(_repo="project_A",_folder='')# Get the list of fullpaths starting from "/dir_A/dir_B/"arti.get_list_path(_repo="project_A",_folder='/dir_A/dir_B/')References:https://pypi.org/project/dohq-artifactory/https://www.jfrog.com/confluence/display/JFROG/Artifactory+Query+Language/