dohq-artifactory: A Python Client for Artifactory

1.0.1 · active · verified Sat Apr 11

dohq-artifactory is an active Python interface library for JFrog Artifactory, released as version 1.0.1. It functions as a logical descendant of Python's `pathlib`, aiming for a similar interface, and was forked from the `parallels/artifactory` project to provide continued support and development. It supports Python versions 3.8 through 3.13. The library enables interaction with Artifactory for tasks such as managing artifacts, searching repositories, and handling administrative functions. It generally follows an on-demand release cadence based on feature development and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to connect to an Artifactory instance using `ArtifactoryPath` and basic authentication. It then shows how to list contents of a repository and check for the existence and properties of a specific artifact, leveraging the `pathlib`-like interface.

import os
from artifactory import ArtifactoryPath

ART_URL = os.environ.get('ARTIFACTORY_URL', 'https://artifactory.example.com/artifactory')
ART_USER = os.environ.get('ARTIFACTORY_USERNAME', 'admin')
ART_PASS = os.environ.get('ARTIFACTORY_PASSWORD', 'password') # Or API Key/Access Token

try:
    # Initialize ArtifactoryPath with URL and authentication
    artifactory_path = ArtifactoryPath(ART_URL, auth=(ART_USER, ART_PASS))

    # Example: List contents of a repository (e.g., 'libs-release')
    repo = artifactory_path / "libs-release"
    print(f"Contents of {repo}:")
    for item in repo:
        print(f"  - {item.name} ({'dir' if item.is_dir() else 'file'})")

    # Example: Access a specific artifact (assuming it exists)
    artifact_path = repo / "com" / "example" / "myapp" / "1.0.0" / "myapp-1.0.0.jar"
    if artifact_path.exists():
        print(f"\nArtifact found: {artifact_path.name}")
        print(f"  Size: {artifact_path.stat().size} bytes")
    else:
        print(f"\nArtifact not found: {artifact_path}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →