小程序原生组件—提升你的小程序体验
764
2022-11-30
NexusAPI调试方法
Nexus API调试方法
进入设置页面, 找到System > API , 即可进入API调试页面。主要用的是获取制品和上传制品。
填写参数信息
执行操作, 204表示成功。 我们可以复用这里的CURL指令, 最后封装到Jenkins流水线当中。
上传制品
curl -u admin:admin123 如果Nexus开启了认证需要配置认证信息才能正常访问。
##PNGcurl -X POST "-H "accept: application/json" -H "Content-Type: multipart/form-data" -F "raw.directory=/tmp" -F "raw.asset1=@默认标题_自定义px_2020-10-01-0.png;type=image/png" -F "raw.asset1.filename=默认标题_自定义px_2020-10-01-0.png"## tar.gz & ZIPcurl -X POST "-H "accept: application/json" -H "Content-Type: multipart/form-data" -F "raw.directory=/tmp" -F "raw.asset1=@nexus-3.30.0-01-unix.tar.gz;type=application/x-gzip" -F "raw.asset1.filename=aaa.tar.gz"curl -X POST "-H "accept: application/json" -H "Content-Type: multipart/form-data" -F "raw.directory=/tmp" -F "raw.asset1=@waypoint_0.1.5_linux_amd64.zip;type=application/x-gzip" -F "raw.asset1.filename=waypoint_0.1.5_linux_amd64.zip"## Jar file curl -X POST "\-H "accept: application/json" \-H "Content-Type: multipart/form-data" \-F "raw.directory=/tmp" \-F "raw.asset1=@aopalliance-1.0.jar;type=application/java-archive" \-F "raw.asset1.filename=aopalliance-1.0.jar"
上传制品(maven类型的制品):
curl -X POST "\ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ -F "maven2.groupId=com.newdevops" \ -F "maven2.artifactId=devopsapp" \ -F "maven2.version=1.1.5" \ -F "maven2.packaging=jar" \ -F "maven2.asset1=@demo-0.0.1-SNAPSHOT.jar;type=application/java-archive" \ -F "maven2.asset1.extension=demo-0.0.1-SNAPSHOT.jar" \ -u admin:admin123
这些用户名密码可以使用Jenkins的凭据
封装为共享库,jenkins代码如下:
package org.devops//上传制品def PushArtifactsByApi(repository,groupId,artifactId,version,packaging,asset,user,passwd){ sh """ curl -X POST "\ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ -F "maven2.groupId=${groupId}" \ -F "maven2.artifactId=${artifactId}" \ -F "maven2.version=${version}" \ -F "maven2.packaging=${packaging}" \ -F "maven2.asset1=@target/${asset};type=application/java-archive" \ -F "maven2.asset1.extension=target/${asset}" \ -u "${user}":"${passwd}" """}@Library("devopslib@main") _def nexus = new org.devops.nexus() stage('Nexus'){ steps{ script{ pkg = sh returnStdout: true, script: """ ls target/ | grep -E "jar\$" """ pkg = pkg - "\n" println(pkg) pkgName = pkg.split("-")[0] pkgVersion = pkg.split("-")[1] pkgType = pkg.split("\\.")[-1] withCredentials([usernamePassword(credentialsId: 'ff93f4bf-9d8c-4fc2-bccd-3e614f10d643', passwordVariable: 'passwd', usernameVariable: 'user')]) { nexus.PushArtifactsByApi("devops-maven","hello.kitty","test",pkgVersion,pkgType,pkg,user,passwd) } } } }
-制品
cURL
curl -u admin:admin123 -o anyops-devops-service-1.1.1.jar
Wget
wget ----http://192.168.1.200:8081/repository/anyops/com/anyops/anyops-devops-service/1.1.1/anyops-devops-service-1.1.1.jar
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~