DEV Community

pr4th4m
pr4th4m

Posted on

Artifactory python client

Py-Artifactory

Artifactory is a artifact repository manager which supports software packages created by different technologies.
It can also be integrated with major CI/CD and DevOps tools.
This article shows how we can communicate with artifactory using a python api client.

Pre-requisites:

  • Python 2.7 or higher
  • libxml2/libxslt (will be deprecated in future releases)
  # Debian based
  sudo apt-get install libxml2-dev libxslt1-dev

  # RedHat based
  sudo yum install libxml2-devel libxslt-devel
Enter fullscreen mode Exit fullscreen mode

Installation:

  • Fire-up below command in terminal, tag specifies a version number.
  pip install git+https://github.com/veritasos/py-artifactory.git@<tag>
Enter fullscreen mode Exit fullscreen mode

Usage:

  • Create client instance
  from artifactory import Artifactory
  artifactory = Artifactory(
          url="http://127.0.0.1:8081",
          username="username",
          password="password",
          )
Enter fullscreen mode Exit fullscreen mode
  • List users
  user_list = artifactory.security.users.list()
Enter fullscreen mode Exit fullscreen mode
  • Get user
  user = artifactory.security.users.fetch("user.name")
Enter fullscreen mode Exit fullscreen mode
  • Create user
  user = artifactory.security.users.new()
  user.name = "first.last"
  user.password = "test"
  user.email = "first.last@testartifactory.com"
  user.groups = ["readers"]
  response = user.create()
Enter fullscreen mode Exit fullscreen mode
  • And much more ......
  Artifactory Users
  Artifactory Groups
  Artifactory Permissions
  Artifactory Repositories
  Artifactory Repository Replication
  Artifactory LDAP
  Artifactory User Api Keys
Enter fullscreen mode Exit fullscreen mode

Detailed documentation:

Top comments (0)