简体   繁体   English

通过python脚本部署到artifactory

[英]Deploy to artifactory via python script

I am trying to create a python script that can deploy an artifact to Artifactory. 我正在尝试创建一个可以将工件部署到Artifactory的python脚本。 I am using Python 3.4 and I want the resulted script to put it through py2exe, so external libraries might create issues. 我正在使用Python 3.4,我希望结果脚本通过py2exe,因此外部库可能会产生问题。

Through all my research, I found that one way is this, but I don't know how to "translate" it to Python: 通过我的所有研究,我发现有一种方法,但我不知道如何将它“翻译”为Python:

curl -X PUT -u user:password --data-binary @/absolute/path/my-utils-2.3.jar "http://localhost/artifactory/my-repo/my/utils/2.3/"

How can I achieve that into Python? 我怎样才能在Python中实现这一目标? Or is it any either way for deploying? 或者它是否可以采用任何一种方式进行部署?

Been trying the whole day and I've had some succesfull testing using the requests library. 一直在尝试,我已经使用请求库进行了一些成功的测试。

import requests

url = "repo/path/test.txt"

    file_name = "test.txt"
    auth=(USERNAME, PASSWORD)


    with open(file_name, 'rb') as fobj:
        res = requests.put(url, auth=auth, data=fobj)
        print(res.text)
        print(res.status_code)

And py2exe had no issues with it. 并且py2exe没有问题。

你可能想看看Party ,看看他们是怎么做的,或者直接使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM