您现在的位置是:热点 >>正文
持续集成流水线中的制品管理(Nexus)
热点55788人已围观
简介...
我们可以在该工作流中通过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']],  集成; credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', groupId: 'com.jenkins', nexusUrl: '192.168.1.200:8081', nexusVersion: 'nexus3', protocol: 'http', &nb流水sp; 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: '', &nbs线中p; file: file, type: type]], credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', groupId: groupId, nexusUrl: '192.168.1.200:8081', 的制 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&nb品管sp;"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 = new&nNebsp;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") &nbxusp; checkout.GetCode("${env.srcUrl}", "${env.branchName}") } } } stage("Build"){ steps{ script{ println("Build") sh "mvn clean package " &nbss)p;} } } stage("UnitTest"){ steps{ script{ unittest.CodeTest("${env.buildTool}") } } } stage("Upload"){ steps{ 持续 script{ NexusUploadByPlugin("${env.artifactId}", 'target/demo-0.0.1-SNAPSHOT.jar', "${env.type}", &nbs集成p; "${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, &nbs流水p; classifier: '', file: file, type: type]], credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559', groupId:&线中nbsp;groupId, nexusUrl: '192.168.1.200:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'mymavenrepo', version: version }
历史与Nexus相关的主题
Tags:
相关文章
Salesforce预计2026财年运营利润率为25% 提高支出效率
热点北京时间9月22日早间消息,据报道,美国企业软件公司Salesforce股价周三宣布了新的长期盈利目标,表明该公司致力于提高运营效率。受此消息影响,该股在当天美股盘后交易中上涨近3% 在新冠疫情期间,...
【热点】
阅读更多标签: 平安好医生 百度健康 何明科 韩帅
热点云梦级3月4日云梦级消息,据《健闻咨询》公众号报道,从2025年11月至今,已有至少三位前百度健康高管入职平安好医生:分别是前百度大健康事业群组(下称“HCG”)生态平台部总经理韩帅、前百度HCG医疗...
【热点】
阅读更多告别繁琐!谷歌Gemini AI让表格处理变得轻松无比
热点近日,谷歌为其电子表格工具 Google Sheets 引入了全新的 Gemini AI 助手,这一升级使得用户在处理数据表格时更加得心应手,省去了不少时间和精力。 早在一年前,谷歌就已推出 “转换为...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.mygrandma.com/Items.aspx?search=谷歌搜索留痕【tg:seogoogle987】,2NH
- https://www.teamlab.art/?submit=谷歌搜索留痕【tg:seogoogle987】,Ij3
- https://www.maine.gov/pfr/professionallicensing/search/node?keys=谷歌搜索留痕【tg:seogoogle987】,KHQ
- https://www.synonyms.com/antonyms/谷歌搜索留痕【tg:seogoogle987】,SGG
- https://www.zalora.sg/catalog/?cat=112&q=谷歌搜索留痕【tg:seogoogle987】,M8J
- https://www.teamlab.art/ko/?submit=谷歌搜索留痕【tg:seogoogle987】,77E
- https://hsmoa.com/search?query=谷歌搜索留痕【tg:seogoogle987】qi5
- https://www.pacific-lifestyle.co.uk/search?sort=alphabetical&term=谷歌搜索留痕【tg:seogoogle987】,CmM
- https://m.shoppinghow.kakao.com/m/search/q/谷歌搜索留痕【tg:seogoogle987】BFo
- https://www.ntv.co.jp/3min/search/?action=QUERY&q=谷歌搜索留痕【tg:seogoogle987】,vAw
- https://search.danawa.com/dsearch.php?query=谷歌搜索留痕【tg:seogoogle987】hpy
- https://www.otakuninjahero.com/en/search/谷歌搜索留痕【tg:seogoogle987】,UYS
- https://m.shoppinghow.kakao.com/m/search/q/谷歌搜索留痕【tg:seogoogle987】YCW
- https://www.wellbees.com/index.php/catalogsearch/result/index/?q=谷歌搜索留痕【tg:seogoogle987】,U6v
- https://www.duksung.ac.kr/search/front/Search.jsp?qt=谷歌搜索留痕【tg:seogoogle987】GAo
- https://www.nonsolocap.it/cap?action=SEARCH&k=谷歌搜索留痕【tg:seogoogle987】,k12
- https://www.smics.com/tc/site/search?token=谷歌搜索留痕【tg:seogoogle987】,M7z
- https://www.yr.no/en/search?q=谷歌搜索留痕【tg:seogoogle987】,ZEf
- https://www.stonerealestate.com.au/?cat=100&s=谷歌搜索留痕【tg:seogoogle987】,JqB
- https://www.spoiledsweetboutique.com/search/谷歌搜索留痕【tg:seogoogle987】,6aJ
- https://www.unclefossil.com/search/谷歌搜索留痕【tg:seogoogle987】,yKV
- https://www.thealexandrian.net/?s=谷歌搜索留痕【tg:seogoogle987】,Jk9
- https://www.toy-people.com/?s=谷歌搜索留痕【tg:seogoogle987】,c4v
- https://www.wmfe.org/?s=谷歌搜索留痕【tg:seogoogle987】,PIq
- https://www.mexperience.com/?T=1686132112324&s=谷歌搜索留痕【tg:seogoogle987】,EtW
- https://www.realsporting.com/buscador?buscar=谷歌搜索留痕【tg:seogoogle987】,DKX
- https://wwwcp.umes.edu/search/谷歌搜索留痕【tg:seogoogle987】,z26
- https://www.parl.ca/legisinfo/fr/projets-de-loi?parlsession=all&view=list&keywords=谷歌搜索留痕【tg:seogoogle987】,akF
- https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=谷歌搜索留痕【tg:seogoogle987】,rM1
- https://www.welshmountainzoo.org/shop/index.php?routeproduct/search&tag=谷歌搜索留痕【tg:seogoogle987】,DnH
- https://zhidao.baidu.com/index/?action=QUERY&word=谷歌搜索留痕【tg:seogoogle987】,sAP
- https://www.parriscues.com/catalogsearch/result/?q=谷歌搜索留痕【tg:seogoogle987】,KkC
- https://www.mynextmove.org/find/search?s=谷歌搜索留痕【tg:seogoogle987】,WqN
- https://www.unclefossil.com/search/谷歌搜索留痕【tg:seogoogle987】gad_source=1&gclid=Cj0KCQjw_-GxBhC1ARIsADGgDjsNKplUXa2F6YGlHBK2sHDQ88cgsJBb05DyO99TV9jNq_cT0kGMqyQaAgHQEALw_wcB
- https://www.wuv.edu/?s=谷歌搜索留痕【tg:seogoogle987】,fiV
- https://www.samen-maier.at/search/谷歌搜索留痕【tg:seogoogle987】,cER
- https://www.southmeadows.co.uk/2019/07/?s=谷歌搜索留痕【tg:seogoogle987】,hrN
- https://www.goodreads.com/quotes/tag/谷歌搜索留痕【tg:seogoogle987】cb3
- https://www.dba.dk/soeg/?soeg=谷歌搜索留痕【tg:seogoogle987】0C5
- https://www.reginatangoshoes.com/en/catalogsearch/result/index/?T=1686132113407&q=谷歌搜索留痕【tg:seogoogle987】,nLy
- https://www.vfw.org/search-results?q=谷歌搜索留痕【tg:seogoogle987】,VoH
- https://www.tiktok.com/tag/谷歌搜索留痕【tg:seogoogle987】,b6I
- https://xehay.vn/tim-kiem/=谷歌搜索留痕【tg:seogoogle987】,jwn
- https://www.zisha.com/shop/list.shtml?wap_keyword=谷歌搜索留痕【tg:seogoogle987】,o10
- https://www.remit.co.jp/en/?s=谷歌搜索留痕【tg:seogoogle987】,lXw
- https://www.sweat.com/collections/vendors?q=谷歌搜索留痕【tg:seogoogle987】,a2c
- https://nicolazzi.it/en/?s=谷歌搜索留痕【tg:seogoogle987】,0qI
- https://www.monroecounty.gov/search/?q=谷歌搜索留痕【tg:seogoogle987】,kwO
- https://www.valuecolleges.com/?action=QUERY&s=谷歌搜索留痕【tg:seogoogle987】,fjR
- https://www.lee.com/search?q=谷歌搜索留痕【tg:seogoogle987】,z3Z