日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
持續(xù)集成流水線中的制品管理(Nexus)

持續(xù)集成流水線中的制品管理(Nexus)

作者:Lizeyang 2021-10-12 08:47:01

云計算 Nexus是一個存儲庫管理器,可存儲和檢索制品。它使您能夠?qū)?gòu)建的制品托管在私有且安全的存儲庫中。默認開發(fā)同學在進行開發(fā)的時候會使用一些包管理工具,例如:maven、ant、gradle這些都是常見項目編譯構(gòu)建工具 。

在善右等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作定制網(wǎng)站開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),網(wǎng)絡(luò)營銷推廣,外貿(mào)營銷網(wǎng)站建設(shè),善右網(wǎng)站建設(shè)費用合理。

我們可以在該工作流中通過Maven和CI服務(wù)器來構(gòu)建,存儲,管理已編譯完成的制品。

Nexus是一個存儲庫管理器,可存儲和檢索制品。它使您能夠?qū)?gòu)建的制品托管在私有且安全的存儲庫中。默認開發(fā)同學在進行開發(fā)的時候會使用一些包管理工具,例如:maven、ant、gradle這些都是常見項目編譯構(gòu)建工具 。這些工具可以理解為是一個命令行工具, 本身不會存儲任何依賴包,而是通過公網(wǎng)官方的倉庫中下載當前項目構(gòu)建所需要的包。(內(nèi)網(wǎng)的速度要比公網(wǎng)快,這會直接影響管道的構(gòu)建速度)

制品上傳

NexusUI頁面

Nexus的UI中提供制品上傳的功能, 導航Upload, 選擇要上傳的目標倉庫。 最后填寫倉庫中包的坐標和包信息。

使用Maven工具

一般倉庫都是需要認證后才能上傳的, 所以首先需要在maven的配置文件中(settings.xml)填寫倉庫的認證信息。

  
 
 
 
  1.  
  2.     mymaven 
  3.     admin 
  4.     admin123 
  5.    

使用mvn deploy 命令上傳發(fā)布制品,命令參數(shù)與格式:

  
 
 
 
  1. mvn deploy:deploy-file 
  2. -DgroupId=xxxxxx pom中的groupId 
  3. -DartifactId=xxxxxx pom中的artifactId 
  4. -Dversion=xxxxxx pom中的版本號version 
  5. -Dpackaging=xxxxxx pom中打包方式 
  6. -Dfile=xxxxxx 本地文件 
  7. -Durl=xxxxxx 倉庫url 
  8. -DrepositoryId=xxxxxx 對應(yīng)的是setting.xml(認證) 

如果此時包已經(jīng)有pom.xml 文件描述, 可以直接通過pom.xml文件進行上傳:

  
 
 
 
  1. mvn deploy:deploy-file \ 
  2. -DgeneratePom=false \ 
  3. -DrepositoryId=mymaven \ 
  4. -Durl=http://192.168.1.200:8081/repository/mymavenrepo \ 
  5. -DpomFile=pom.xml \ 
  6. -Dfile=target/demo-0.0.1-SNAPSHOT.jar 

使用Jenkins插件

安裝Nexus Artifact Uploader插件、使用片段生成器生成DSL。

  
 
 
 
  1. nexusArtifactUploader   artifacts: [[artifactId: 'DevOpstest',  
  2.                                     classifier: '',  
  3.                                     file: 'target/demo-0.0.1-SNAPSHOT.jar',  
  4.                                     type: 'jar']],  
  5.                         credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559',  
  6.                         groupId: 'com.jenkins',  
  7.                         nexusUrl: '192.168.1.200:8081',  
  8.                         nexusVersion: 'nexus3',  
  9.                         protocol: 'http',  
  10.                         repository: 'mymavenrepo',  
  11.                         version: '1.1.2' 

擴展: 如果需要經(jīng)常上傳制品, 我們最后將其封裝在一個函數(shù)中,便于復(fù)用。

  
 
 
 
  1. //NexusUploadByPlugin('devops-test', 'target/demo-0.0.1-SNAPSHOT.jar', 'jar', 'com.jenkins','1.1.2') 
  2.  
  3. def NexusUploadByPlugin(artifactId, file, type, groupId,version){ 
  4.     nexusArtifactUploader   artifacts: [[artifactId: artifactId,  
  5.                                     classifier: '',  
  6.                                     file: file,  
  7.                                     type: type]],  
  8.                         credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559',  
  9.                         groupId: groupId,  
  10.                         nexusUrl: '192.168.1.200:8081',  
  11.                         nexusVersion: 'nexus3',  
  12.                         protocol: 'http',  
  13.                         repository: 'mymavenrepo',  
  14.                         version: version 

使用Nexus API

經(jīng)過調(diào)試,整理如下類型文件上傳的接口:

  
 
 
 
  1. ##PNG 
  2. curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" \ 
  3. -H "accept: application/json" \ 
  4. -H "Content-Type: multipart/form-data" \ 
  5. -F "raw.directory=/tmp" \ 
  6. -F "raw.asset1=@默認標題_自定義px_2020-10-01-0.png;type=image/png" \ 
  7. -F "raw.asset1.filename=默認標題_自定義px_2020-10-01-0.png" 
  8.  
  9.  
  10. ## tar.gz & ZIP 
  11. curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" \ 
  12. -H "accept: application/json" \ 
  13. -H "Content-Type: multipart/form-data" \ 
  14. -F "raw.directory=/tmp" \ 
  15. -F "raw.asset1=@nexus-3.30.0-01-unix.tar.gz;type=application/x-gzip" \ 
  16. -F "raw.asset1.filename=aaa.tar.gz" 
  17.  
  18.  
  19. 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" 
  20.  
  21.  
  22. ## Jar file  
  23. curl -X POST "http://192.168.1.200:8081/service/rest/v1/components?repository=myrepo" \ 
  24. -H "accept: application/json" \ 
  25. -H "Content-Type: multipart/form-data" \ 
  26. -F "raw.directory=/tmp" \ 
  27. -F "raw.asset1=@aopalliance-1.0.jar;type=application/java-archive" \ 
  28. -F "raw.asset1.filename=aopalliance-1.0.jar" 

下載制品

cURL

  
 
 
 
  1. curl -u admin:admin123 http://192.168.1.200:8081/repository/anyops/com/anyops/a 
  2. nyops-devops-service/1.1.1/anyops-devops-service-1.1.1.jar -o anyops-devops-service-1.1.1.jar 

Wget

  
 
 
 
  1. wget --http-user=admin --http-passwd=admin123 http://192.168.1.200:8081/repos 
  2. itory/anyops/com/anyops/anyops-devops-service/1.1.1/anyops-devops-service-1.1.1.jar 

案例: 配置制品上傳Pipeline

其實我們可以參考Nexus的UI頁面, 使用Jenkins來做一個用于上傳制品包的流水線作業(yè):

  • srcUrl 指的是源碼包的源碼/包的倉庫;
  • branchName 源碼包倉庫的分支;
  • groupId、artifactid、 version maven類型倉庫的坐標;
  • type 包類型;

這個Jenkinsfile包含4個階段, 分別是下載代碼、代碼編譯、單元測試、上傳制品。

  
 
 
 
  1. @Library("mylib@main") _ 
  2. import org.devops.* 
  3.  
  4. def checkout = new Checkout() 
  5. def build = new Build() 
  6. def unittest = new UnitTest() 
  7. def sonar = new Sonar() 
  8.  
  9. pipeline { 
  10.     agent { label "build" } 
  11.  
  12.     options { 
  13.         skipDefaultCheckout true 
  14.     } 
  15.  
  16.  
  17.     stages{ 
  18.         stage("Checkout"){ 
  19.             steps{ 
  20.                 script { 
  21.                     println("GetCode") 
  22.                     checkout.GetCode("${env.srcUrl}", "${env.branchName}") 
  23.                 } 
  24.             } 
  25.         } 
  26.  
  27.         stage("Build"){ 
  28.             steps{ 
  29.                 script{ 
  30.                     println("Build") 
  31.                     sh "mvn clean package " 
  32.                 } 
  33.             } 
  34.         } 
  35.  
  36.         stage("UnitTest"){ 
  37.             steps{ 
  38.                 script{ 
  39.                     unittest.CodeTest("${env.buildTool}") 
  40.                 } 
  41.             } 
  42.         } 
  43.  
  44.         stage("Upload"){ 
  45.             steps{ 
  46.                 script{ 
  47.                     NexusUploadByPlugin("${env.artifactId}",  
  48.                                         'target/demo-0.0.1-SNAPSHOT.jar',  
  49.                                         "${env.type}",  
  50.                                         "${env.groupId}", 
  51.                                         "${env.version}") 
  52.                 } 
  53.             } 
  54.         } 
  55.     } 
  56.  
  57. //NexusUploadByPlugin('devops-test', 'target/demo-0.0.1-SNAPSHOT.jar', 'jar', 'com.jenkins','1.1.2') 
  58.  
  59. def NexusUploadByPlugin(artifactId, file, type, groupId,version){ 
  60.     nexusArtifactUploader   artifacts: [[artifactId: artifactId,  
  61.                                     classifier: '',  
  62.                                     file: file,  
  63.                                     type: type]],  
  64.                         credentialsId: '1de05a13-197c-4a72-8c6a-cd330fc45559',  
  65.                         groupId: groupId,  
  66.                         nexusUrl: '192.168.1.200:8081',  
  67.                         nexusVersion: 'nexus3',  
  68.                         protocol: 'http',  
  69.                         repository: 'mymavenrepo',  
  70.                         version: version 

歷史與Nexus相關(guān)的主題

本文轉(zhuǎn)載自微信公眾號「DevOps云學堂」


名稱欄目:持續(xù)集成流水線中的制品管理(Nexus)
標題網(wǎng)址:http://www.dlmjj.cn/article/djecogh.html