您现在的位置是:热点 >>正文
持续集成流水线中的制品管理(Nexus)
热点9094420人已围观
简介...
我们可以在该工作流中通过Maven和CI服务器来构建,存储,管理已编译完成的制品。
Nexus是一个存储库管理器,可存储和检索制品。它使您能够将构建的制品托管在私有且安全的存储库中。默认开发同学在进行开发的时候会使用一些包管理工具,例如:maven、ant、gradle这些都是常见项目编译构建工具 。这些工具可以理解为是一个命令行工具, 本身不会存储任何依赖包,而是通过公网官方的仓库中下载当前项目构建所需要的包。(内网的速度要比公网快,这会直接影响管道的构建速度)
制品上传 NexusUI页面
Nexus的UI中提供制品上传的功能, 导航Upload, 选择要上传的目标仓库。 最后填写仓库中包的坐标和包信息。
使用Maven工具
一般仓库都是需要认证后才能上传的, 所以首先需要在maven的配置文件中(settings.xml)填写仓库的认证信息。
mymaven admin admin123
使用mvn deploy 命令上传发布制品,命令参数与格式:
mvn deploy:deploy-file -DgroupId=xxxxxx pom中的groupId -DartifactId=xxxxxx pom中的artifactId -Dversion=xxxxxx pom中的版本号version -Dpackaging=xxxxxx pom中打包方式 -Dfile=xxxxxx 本地文件 -Durl=xxxxxx 仓库url -DrepositoryId=xxxxxx 对应的是setting.xml(认证)
如果此时包已经有pom.xml 文件描述, 可以直接通过pom.xml文件进行上传:
mvn deploy:deploy-file -DgeneratePom=false -DrepositoryId=mymaven -Durl=http://192.168.1.200:8081/repos持续itory/mymavenrepo -DpomFile=pom.xml -Dfile=target/demo-0.0.1-SNAPSHOT.jar 使用Jenkins插件
安装Nexus Artifact Uploader插件、使用片段生成器生成DSL。
nexusArtifactUploader artifacts: [[artifactId: 'devopstest', classifier: '', file: 'target/demo-0.0.1-SNAPSHOT.jar', type: 'jar']], &nb集成sp; credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', groupId: 'com.jenkins', nexusUrl: '192.168.1.200:8081', nexusVersion: 'nexus3', protocol: 'http',  流水; repository: 'mymavenrepo', version: '1.1.2'
扩展: 如果需要经常上传制品, 我们最后将其封装在一个函数中,便于复用。
//NexusUploadByPlugin('devops-test', 'target/demo-0.0.1-SNAPSHOT.jar', 'jar', 'com.jenkins','1.1.2') def NexusUploadByPlugin(artifactId, file, type, groupId,version){ nexusArtifactUploader artifacts: [[artifactId: artifactId, classifier: '', &n线中bsp; file: file, type: type]], credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', groupId: groupId, nexusUrl: '192.168.1.200:8081', &的制nbsp; nexusVersion: 'nexus3', protocol: 'http', repository: 'mymavenrepo', version: version } 使用Nexus API
经过调试,整理如下类型文件上传的接口:
##PNG curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" -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 & ZIP curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "raw.directory=/tmp" -F "[email protected];type=application/x-gzip" -F "raw.asset1.filename=aaa.tar.gz" curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" -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 "http://192.168.1.200:8081/service/rest/v1/componen理(ts?repository=myrepo" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "raw.directory=/tmp" -F "[email protected];type=application/java-archive" -F "raw.asset1.filename=aopalliance-1.0.jar" 下载制品 cURL curl -u admin:admin123 http://192.168.1.200:8081/repository/anyops/com/anyops/a nyops-devops-service/1.1.1/anyops-devops-service-1.1.1.jar -o anyops-devops-service-1.1.1.jar Wget wget --http-user=admin --http-passwd=admin123 http://192.168.1.200:8081/repos itory/anyops/com/anyops/anyops-devops-service/1.1.1/anyops-devops-service-1.1.1.jar 案例: 配置制品上传Pipeline
其实我们可以参考Nexus的UI页面, 使用Jenkins来做一个用于上传制品包的流水线作业:
srcUrl 指的是源码包的源码/包的仓库; branchName 源码包仓库的分支; groupId、artifactid、 version maven类型仓库的坐标; type 包类型;
这个Jenkinsfile包含4个阶段, 分别是下载代码、代码编译、单元测试、上传制品。
@Library("mylib@main") _ import org.devops.* def checkout = neNew Checkout() def build = new Build() def unittest = new UnitTest() def sonar = new Sonar() pipeline { agent { label "build" } options { skipDefaultCheckout true } stages{ stage("Checkout"){ steps{ script { println("GetCode") &xunbsp; checkout.GetCode("${env.srcUrl}", "${env.branchName}") } } } stage("Build"){ steps{ script{ println("Build") sh "mvn clean package " &s)nbsp;} } } stage("UnitTest"){ steps{ script{ unittest.CodeTest("${env.buildTool}") } } } stage("Upload"){ steps{ &nb持续sp; script{ NexusUploadByPlugin("${env.artifactId}", 'target/demo-0.0.1-SNAPSHOT.jar', "${env.type}", &nb集成sp; "${env.groupId}", "${env.version}") } } } } } //NexusUploadByPlugin('devops-test', 'target/demo-0.0.1-SNAPSHOT.jar', 'jar', 'com.jenkins','1.1.2') def NexusUploadByPlugin(artifactId, file, type, groupId,version){ nexusArtifactUploader artifacts: [[artifactId: artifactId, &nb流水sp; classifier: '', file: file, type: type]], credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', g线中roupId: groupId, nexusUrl: '192.168.1.200:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'mymavenrepo', version: version }
历史与Nexus相关的主题
Tags:
相关文章
标签: 小赢科技 WinPROT赢护 Win-Daidai 金融科技
热点云梦级3月26日云梦级消息,3月26日,中国金融科技公司小赢科技发布了其截至2025年12月31日的第四季度及年度未经审计的财务业绩。财务数据显示:2025财年净收入总额为人民币76.394亿元,20...
【热点】
阅读更多标签: 高途 高途集团 GOTU AllWithAI
热点云梦级6月2日云梦级消息,2026年6月2日,集团(NYSE: GOTU)正式发布了截至2026年3月31日的第一季度财务报告。高途本季度不仅延续了稳健的收入增长态势,更实现了非美国通用会计准则下经营...
【热点】
阅读更多标签: 迅策科技 Token业务 ARPU 海外业务
热点云梦级8月22日云梦级消息,迅策科技(03317.HK)于8月21日发布2026年中期业绩报告。财报显示,迅策科技今年上半年实现营收9.67亿元,同比大幅增长389%,创下同期历史新高;归母净利润72...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.sonepar.ch/fr/search?q=谷歌快排操作流程【tg:seogoogle987】,8yq
- https://www.totolink.vn/search/谷歌快排操作流程【tg:seogoogle987】,3oZ
- https://www.spicebar.de/catalogsearch/result/?q=谷歌快排操作流程【tg:seogoogle987】,0kX
- https://www.tombow.com/search/谷歌快排操作流程【tg:seogoogle987】,Wsc
- https://www.msrenewal.com/search/谷歌快排操作流程【tg:seogoogle987】,K1B
- https://www.vivaraise.fr/catalogsearch/result/?q=谷歌快排操作流程【tg:seogoogle987】,N4F
- https://www.wilsonart.com/catalogsearch/result/?action=CHECK&q=谷歌快排操作流程【tg:seogoogle987】,9MV
- https://www.monroecounty.gov/search/?q=谷歌快排操作流程【tg:seogoogle987】,V2y
- https://www.target.com/s?searchTerm=谷歌快排操作流程【tg:seogoogle987】,Qtc
- https://www.kaskus.co.id/search?q=谷歌快排操作流程【tg:seogoogle987】,jKw
- https://store.line.me/search/sticker/ja?q=谷歌快排操作流程【tg:seogoogle987】L5e
- https://www.ng-slo.si/si/iskanje?cat=114&q=谷歌快排操作流程【tg:seogoogle987】,n2e
- https://www2.ual.es/ProyectoLates/?s=谷歌快排操作流程【tg:seogoogle987】,D1P
- https://www.luxurysociety.com/en/search?q=谷歌快排操作流程【tg:seogoogle987】,cN1
- https://www.mexperience.com/?T=1686132112324&s=谷歌快排操作流程【tg:seogoogle987】,SH6
- https://hsmoa.com/search?query=谷歌快排操作流程【tg:seogoogle987】nvC
- https://www.resopal.de/catalogsearch/result/?action=SEARCH&q=谷歌快排操作流程【tg:seogoogle987】,pHu
- https://www.polliwogs.com/search/谷歌快排操作流程【tg:seogoogle987】,zow
- https://www.nctsn.org/search?cat=191&query=谷歌快排操作流程【tg:seogoogle987】,iZE
- https://www.hanbat.ac.kr/search/front/Search.jsp?qt=谷歌快排操作流程【tg:seogoogle987】lw3
- https://www.vfw.org/search-results?q=谷歌快排操作流程【tg:seogoogle987】,SCM
- https://www.solerpalau.com/en-en/catalogsearch/result/?q=谷歌快排操作流程【tg:seogoogle987】,unb
- https://www.lauben.com/en/?action=SEARCH&s=谷歌快排操作流程【tg:seogoogle987】,Tp2
- https://www.sweat.com/collections/vendors?q=谷歌快排操作流程【tg:seogoogle987】,DUL
- https://www.partilerdunyasi.com/index.php?route=product/search&tag=谷歌快排操作流程【tg:seogoogle987】,cRT
- https://www.duksung.ac.kr/search/front/Search.jsp?qt=谷歌快排操作流程【tg:seogoogle987】DJZ
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌快排操作流程【tg:seogoogle987】02J
- https://www.remit.co.jp/vi/?s=谷歌快排操作流程【tg:seogoogle987】,WKP
- https://www.teacherspayteachers.com/Browse/Search:谷歌快排操作流程【tg:seogoogle987】,44k
- https://www.metaltix.com/?view=tours&filter=search&q=谷歌快排操作流程【tg:seogoogle987】,jDS
- https://www.losgatoschamber.com/list/search?action=SEARCH&q=谷歌快排操作流程【tg:seogoogle987】,Pp9
- https://www.theaerogroup.net/?cat=28&s=谷歌快排操作流程【tg:seogoogle987】,KAo
- https://www.seagrant.wisc.edu/?page=63&s=谷歌快排操作流程【tg:seogoogle987】,VuA
- https://www.teamlab.art/fr/?submit=谷歌快排操作流程【tg:seogoogle987】,g5q
- https://www.military-history.org/?s=谷歌快排操作流程【tg:seogoogle987】,ufB
- https://www.revere.org/search?action=SEARCH&q=谷歌快排操作流程【tg:seogoogle987】,GIv
- https://www.maigoo.com/search/?block=&q=谷歌快排操作流程【tg:seogoogle987】,bn3
- https://www.roberthalf.com/us/en/jobs/all/谷歌快排操作流程【tg:seogoogle987】M9C
- https://www.zalora.sg/catalog/?cat=112&q=谷歌快排操作流程【tg:seogoogle987】,rTf
- https://yokohama-oht.com/?action=CHECK&s=谷歌快排操作流程【tg:seogoogle987】,Z2y
- https://www.tmtpost.com/search?q=谷歌快排操作流程【tg:seogoogle987】,spf
- https://www.scq.ubc.ca/?page=2&s=谷歌快排操作流程【tg:seogoogle987】,oD8
- https://search.danawa.com/dsearch.php?query=谷歌快排操作流程【tg:seogoogle987】j2E
- https://www.woorden.org/spreekwoord.php?woord=谷歌快排操作流程【tg:seogoogle987】,ARe
- https://www.wikiart.org/pt/Search/谷歌快排操作流程【tg:seogoogle987】,7yJ
- https://www.teamlab.art/pt/?submit=谷歌快排操作流程【tg:seogoogle987】,JQK
- https://www.realsporting.com/buscador?buscar=谷歌快排操作流程【tg:seogoogle987】,Wr1
- https://www.youthforum.org/search-results?cx=4f5236218ab5e8ef9&ie=UTF-8&q=谷歌快排操作流程【tg:seogoogle987】,lYj
- https://www.nslcleaders.org/?s=谷歌快排操作流程【tg:seogoogle987】,Eep
- https://www.lauben.com/de/?s=谷歌快排操作流程【tg:seogoogle987】,fqD