持续集成流水线中的制品管理(Nexus)
我们可以在该工作流中通过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']], &nbs集成p; 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: '', &n线中bsp; 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 "raw.as品管set1.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/components?repositor理(y=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 Checkout(Ne) 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") &nbsxup; checkout.GetCode("${env.srcUrl}", "${env.branchName}") } } } stage("Build"){ steps{ script{ println("Build") sh "mvn clean package " } &nbs)sp; } } stage("UnitTest"){ steps{ script{ unittest.CodeTest("${env.buildTool}") } } } stage("Upload"){ steps{ &nbs持续p; script{ NexusUploadByPlugin("${env.artifactId}", 'target/demo-0.0.1-SNAPSHOT.jar', "${env.type}",  集成; "${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,  流水; classifier: '', 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相关的主题
- ·用开源项目AutoXGB助力AutoML开发,实现几行代码构建应用API 译文
- ·天翼云2023年上半年营收459亿元 同比增长63.4%
- ·云计算核心技术Docker教程:将 docker 日志与远程日志驱动程序一起使用
- ·港大携手快手可灵突破长视频一致性瓶颈,"记忆检索"技术震撼发布
- ·寰�蒋楂樼�瑙h�2021璐㈠勾Q4璐㈡姤锛氫簯涓氬姟澧為暱鏄�暱鏈熸寔涔呯殑
- ·标签: 瑞声科技 Dispelix AR光波导 XR
- ·字节跳动发布全新开源长文本处理模型 Seed-OSS-36B
- ·标签: 美团 AITransformation 牧遥 微信AI
- ·Facebook被指歧视合同工:要么线下复工,要么被炒鱿鱼
- ·Intel 11代桌面酷睿1月量产:提前俩月出货
- ·云计算核心技术Docker教程:Docker Swarm 模式管理集群列出节点
- ·标签: 国家新闻出版署 国产网络游戏 游戏审批 2026年2月
- ·云计算开发:Python3-isupper()方法详解
- ·AigcPanel 1.3.0版本重磅更新,直播与图像生成双双上线
- ·璋锋瓕绗�簩瀛e害骞垮憡鎬绘敹鍏ュぇ澧�69%
- ·联邦法官裁定针对苹果数字内容购买和租赁的集体诉讼可以继续进行
- ·https://www.qidulp.com/search?query=谷歌快排操作流程【tg:seogoogle987】,4eU
- ·https://www.krisinformation.se/en/search?q=谷歌快排操作流程【tg:seogoogle987】,WhO
- ·https://www.samen-maier.at/search/谷歌快排操作流程【tg:seogoogle987】,Pv1
- ·https://www.paspaley.com/catalogsearch/result/?action=QUERY&q=谷歌快排操作流程【tg:seogoogle987】,YCy
- ·https://www.mesec.cz/vyhledavani/?qs=谷歌快排操作流程【tg:seogoogle987】,68G
- ·https://www.goodreads.com/quotes/tag/谷歌快排操作流程【tg:seogoogle987】2fa
- ·https://www.umc.edu/search.aspx?ID=I4gnDKRS991MFcIDDzoYze4aWSAszAm7&q=谷歌快排操作流程【tg:seogoogle987】,G5e
- ·https://www.teamlab.art/zh-hans/?submit=谷歌快排操作流程【tg:seogoogle987】,rbS
- ·https://www.zisha.com/shop/list.shtml?wap_keyword=谷歌快排操作流程【tg:seogoogle987】,c9R
- ·https://www.therapeuticassociates.com/?cat=5&s=谷歌快排操作流程【tg:seogoogle987】,tyk
