成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

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

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

[[428249]]

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

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

制品上傳

NexusUI頁面

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

使用Maven工具

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

  1. <server> 
  2.     <id>mymaven</id> 
  3.     <username>admin</username> 
  4.     <password>admin123</password
  5.   </server> 

使用mvn deploy 命令上傳發布制品,命令參數與格式:

  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 對應的是setting.xml(認證) 

如果此時包已經有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' 

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

  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

經過調試,整理如下類型文件上傳的接口:

  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來做一個用于上傳制品包的流水線作業:

  • 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相關的主題

本文轉載自微信公眾號「DevOps云學堂」

 

責任編輯:姜華 來源: DevOps云學堂
相關推薦

2023-05-26 08:31:09

2018-10-23 16:35:19

華為云

2017-03-02 14:12:13

流水線代碼Clojure

2017-02-28 15:40:30

Docker流水線Azure

2013-06-06 09:31:52

2021-06-26 14:22:34

Tekton流水線Kubernetes

2022-01-26 08:12:42

Jenkins開源流水線

2017-02-28 16:00:45

DevOpsMarkdownreST

2022-07-18 06:05:28

Gitlab流水線

2023-05-10 15:08:00

Pipeline設計模式

2024-01-07 12:47:35

Golang流水線設計模式

2021-11-08 07:41:16

Go流水線編程

2021-12-24 08:02:48

GitLabCI模板庫流水線優化

2023-08-18 10:24:52

GitLabCI 流水線

2021-04-13 06:15:37

開源部署流水線Jenkins

2024-05-30 14:18:04

2020-10-25 11:28:12

開源端到端流水線

2021-06-18 05:48:02

Tekton DevopsKubernetes

2023-09-27 08:24:49

2021-06-28 06:32:46

Tekton Kubernetes Clone
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品美女久久久 | 欧美一区二区综合 | 国产精品一区二区在线观看 | 国产精品 欧美精品 | 一区二区视频在线 | 中文精品一区二区 | 国产在线激情视频 | 五月天婷婷综合 | 亚洲综合在线视频 | 欧美日韩一区二区在线观看 | 中文字幕免费 | 九九热在线视频免费观看 | 黄色毛片在线观看 | 成人久久久久久久久 | 夜夜精品浪潮av一区二区三区 | 日本精品一区二区三区在线观看 | 欧美精产国品一二三区 | 成人精品一区二区三区中文字幕 | 日韩欧美国产精品一区二区三区 | 国产超碰人人爽人人做人人爱 | 一级欧美一级日韩片免费观看 | 又爽又黄axxx片免费观看 | 99色综合 | 亚洲视频免费 | 一区二区三区四区国产 | 亚洲成人久久久 | www久久av| 成人区一区二区三区 | 亚洲vs天堂 | re久久 | 亚洲欧美一区在线 | 精品电影| 精品久久久久久亚洲精品 | 亚洲精品一区中文字幕 | 爱爱视频日本 | 亚洲欧美视频在线观看 | 久久精品国产一区二区电影 | www.com久久久 | 在线免费观看色 | 亚洲精品久久久久久久久久久久久 | 精品视频久久久久久 |