欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python實(shí)現(xiàn)批量上傳本地maven庫(kù)到nexus

 更新時(shí)間:2024年01月14日 14:30:34   作者:onlyonexhj  
這篇文章主要為大家詳細(xì)介紹了如何使用Python實(shí)現(xiàn)批量上傳本地maven庫(kù)到nexus,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的小伙伴可以參考下

背景:外包類項(xiàng)目開發(fā)時(shí)是調(diào)用的公司maven倉(cāng)庫(kù)進(jìn)行開發(fā),交付后需要將maven倉(cāng)庫(kù)轉(zhuǎn)移到客戶環(huán)境。

原理:

1、打開idea運(yùn)行源代碼,將maven包下載到本地倉(cāng)庫(kù),

2、下載包所在目錄中執(zhí)行腳本將本地倉(cāng)庫(kù)的maven包上傳到客戶nexus

腳本代碼如下:

# -*- coding: utf-8 -*-
import os
import subprocess
 
# releases倉(cāng)庫(kù)地址
REPO_URL_RELEASES = "http://192.168.2.230:8081/repository/hosted-release/"
# snapshots倉(cāng)庫(kù)地址
REPO_URL_SNAPSHOTS = "http://192.168.2.230:8081/repository/hosted-snapshot/"
 
 
USERNAME = "admin"
PASSWORD = "admin"
 
def upload_files(repo_url, username, password):
    for root, dirs, files in os.walk("."):
        for file_name in files:
            if file_name.endswith(".sh"):
                continue
            if file_name.startswith("."):
                continue
            if "-SNAPSHOT" in root:
                continue
            if "_remote.repositories" in file_name:
                continue
            if file_name.startswith("^archetype-catalog.xml") or file_name.startswith("^maven-metadata-local.xml") or file_name.startswith("^maven-metadata-deployment.xml"):
                continue
 
            file_path = os.path.join(root, file_name)
            upload_url = os.path.join(repo_url, file_path[2:])
            curl_command = ["curl", "-u", "{}:{}".format(username, password), "-X", "PUT", "-v", "-T", file_path, upload_url]
 
            try:
                subprocess.check_call(curl_command)
            except subprocess.CalledProcessError as e:
                print("Failed to upload {}: {}".format(file_path, e))
            else:
                print("Uploaded: {}".format(file_path))
 
if __name__ == "__main__":
    print("Uploading releases...")
    upload_files(REPO_URL_RELEASES, USERNAME, PASSWORD)
 
    print("\nUploading snapshots...")
    upload_files(REPO_URL_SNAPSHOTS, USERNAME, PASSWORD)

到此這篇關(guān)于Python實(shí)現(xiàn)批量上傳本地maven庫(kù)到nexus的文章就介紹到這了,更多相關(guān)Python上傳本地maven到nexus內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論