3 changed files with 181 additions and 0 deletions
@ -0,0 +1,41 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
# -*- coding: utf-8 -*- |
||||||
|
#================== |
||||||
|
# Author: Alvis Zhao |
||||||
|
# Date: 2020-08-14 15:27:05 |
||||||
|
# LastEditTime: 2020-08-14 15:27:57 |
||||||
|
# Description: 批量上传deb包到内网nexus源 |
||||||
|
#================== |
||||||
|
|
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
def showUsage(): |
||||||
|
print("Usage:") |
||||||
|
print(" python upload-apt.py dir-to-upload") |
||||||
|
|
||||||
|
USERNAME="uploader" |
||||||
|
PASSWORD="uploader" |
||||||
|
URL="http://nexus3.developer.com/service/rest/v1/components?repository=bionic" |
||||||
|
|
||||||
|
def main(): |
||||||
|
if len(sys.argv) < 2: |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
uploadDir=sys.argv[1] |
||||||
|
if not os.path.isdir(uploadDir): |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
fileList=os.listdir(uploadDir) |
||||||
|
for file in fileList: |
||||||
|
filepath = uploadDir + os.sep + file |
||||||
|
print(filepath) |
||||||
|
cmd = "curl POST -u " + USERNAME + ":" + PASSWORD + " " + URL + ' -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "apt.asset=@' + filepath + '"' |
||||||
|
os.popen(cmd) |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
main() |
@ -0,0 +1,92 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
# -*- coding: utf-8 -*- |
||||||
|
#================== |
||||||
|
# Author: Alvis Zhao |
||||||
|
# Date: 2020-08-14 15:28:10 |
||||||
|
# LastEditTime: 2020-08-14 15:29:25 |
||||||
|
# Description: 批量上传gradle缓存到内网nexus3仓库 |
||||||
|
#================== |
||||||
|
|
||||||
|
|
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
def showUsage(): |
||||||
|
print("Usage:") |
||||||
|
print(" python upload-gradle-cache.py files-2.1") |
||||||
|
print(" gradle cache dir is at USER_HOME\.gradle\caches\modules-2\files-2.1") |
||||||
|
|
||||||
|
USERNAME="uploader" |
||||||
|
PASSWORD="uploader" |
||||||
|
URL="http://nexus3.developer.com/service/rest/v1/components?repository=maven-public" |
||||||
|
|
||||||
|
# |
||||||
|
# gradle缓存目录结构 |
||||||
|
# files-2.1 |
||||||
|
# |_groupId |
||||||
|
# |_artifactId |
||||||
|
# |_version |
||||||
|
# |_xxx |
||||||
|
# | |_artifactId-version.pom // pom配置,一定存在 |
||||||
|
# |_xxx |
||||||
|
# | |_artifactId-version.aar/jar |
||||||
|
# |_xxx |
||||||
|
# |_artifactId-version-classifier.jar |
||||||
|
# |
||||||
|
|
||||||
|
def main(): |
||||||
|
if len(sys.argv) < 2: |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
uploadDir=sys.argv[1] |
||||||
|
if not os.path.isdir(uploadDir): |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
groupList=os.listdir(uploadDir) |
||||||
|
for one in groupList: |
||||||
|
groupId = one |
||||||
|
groupPath = uploadDir + os.sep + groupId |
||||||
|
artifactList=os.listdir(groupPath) |
||||||
|
for two in artifactList: |
||||||
|
artifactId = two |
||||||
|
artifactPath = groupPath + os.sep + artifactId |
||||||
|
versionList=os.listdir(artifactPath) |
||||||
|
for three in versionList: |
||||||
|
version = three |
||||||
|
versionPath = artifactPath + os.sep + version |
||||||
|
hasList = os.listdir(versionPath) |
||||||
|
num = 1 |
||||||
|
|
||||||
|
cmd = "curl -v -u " + USERNAME + ":" + PASSWORD |
||||||
|
cmd = cmd + " -X POST " |
||||||
|
cmd = cmd + ' -H "accept:application/json"' |
||||||
|
cmd = cmd + ' -H "Content-Type:multipart/form-data"' |
||||||
|
cmd = cmd + ' -F maven2.generate-pom=false' |
||||||
|
cmd = cmd + ' -F maven2.groupId=' + groupId |
||||||
|
cmd = cmd + ' -F maven2.artifactId=' + artifactId |
||||||
|
cmd = cmd + ' -F maven2.version=' + version |
||||||
|
for hash in hasList: |
||||||
|
hashPath = versionPath + os.sep + hash |
||||||
|
fileList = os.listdir(hashPath) |
||||||
|
file = fileList[0] |
||||||
|
cmd = cmd + " -F maven2.asset" + str(num) + "=@" + str(hashPath) + os.sep + file |
||||||
|
arr = os.path.splitext(file) |
||||||
|
# extension = aar/jar/pom |
||||||
|
extension = arr[1].split('.')[1] |
||||||
|
cmd = cmd + " -F maven2.asset" + str(num) + ".extension=" + extension |
||||||
|
# basename = artifactPath-version-classifier |
||||||
|
basename = arr[0] |
||||||
|
tmpClassifier = basename.split(artifactId + "-")[1].split(version)[1] |
||||||
|
# 可能没有classifier |
||||||
|
if len(tmpClassifier) > 0: |
||||||
|
classifier = tmpClassifier.split('-')[1] |
||||||
|
cmd = cmd + " -F maven2.asset" + str(num) + ".classifier=" + classifier |
||||||
|
cmd = cmd + " " + URL |
||||||
|
os.system(cmd) |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
main() |
@ -0,0 +1,48 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
# -*- coding: utf-8 -*- |
||||||
|
|
||||||
|
#================== |
||||||
|
# Author: Alvis Zhao |
||||||
|
# Date: 2020-08-14 15:27:05 |
||||||
|
# LastEditTime: 2020-08-14 15:30:46 |
||||||
|
# Description: 批量上传npm包到内网nexus源 |
||||||
|
#================== |
||||||
|
|
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
def showUsage(): |
||||||
|
print("Usage:") |
||||||
|
print(" npm adduser --register http://nexus3.developer.com/repository/npm-public") |
||||||
|
print(" python upload-npm.py dir-to-upload") |
||||||
|
|
||||||
|
USERNAME="uploader" |
||||||
|
PASSWORD="uploader" |
||||||
|
URL="http://nexus3.developer.com/repository/npm-public" |
||||||
|
|
||||||
|
def loginNpmRepo(): |
||||||
|
pipeline = os.popen('npm config set registry ' + URL) |
||||||
|
cmd = 'npm-cli-login -u "' + USERNAME + '" -p "' + PASSWORD + '" -e test@example.com -r ' + URL |
||||||
|
pipeline = os.popen(cmd) |
||||||
|
print(pipeline) |
||||||
|
|
||||||
|
def main(): |
||||||
|
if len(sys.argv) < 2: |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
uploadDir=sys.argv[1] |
||||||
|
if not os.path.isdir(uploadDir): |
||||||
|
print("用法错误!") |
||||||
|
showUsage() |
||||||
|
return |
||||||
|
|
||||||
|
fileList=os.listdir(uploadDir) |
||||||
|
for file in fileList: |
||||||
|
filepath = os.getcwd() + os.sep + uploadDir + os.sep + file |
||||||
|
cmd = "npm publish " + filepath |
||||||
|
os.system(cmd) |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
main() |
Loading…
Reference in new issue