当前位置: 代码迷 >> 综合 >> Nexus 06 使用Jenkins nexus 插件发布制品
  详细解决方案

Nexus 06 使用Jenkins nexus 插件发布制品

热度:84   发布时间:2023-09-30 12:29:28.0

拿到制品的核心就是定位制品,仓库URL+GroupID+ArtifactId+Version就可以定位一个制品

使用Jenkins插件发布制品


Nexus 06 使用Jenkins nexus 插件发布制品 发布其实就是下载制品,然后将制品发送到目标主机,最后通过脚本或者指令启动程序。

 下面是下载制品的示例:

curl http://192.168.1.200:8081/repository/devops-maven/com/example/demo/1.1.10/demo-1.1.10.jar -o app.jar -uadmin:admin123

现在我要用插件列出这个制品不同的版本,并且赋值给变量artifatUrl 

Nexus 06 使用Jenkins nexus 插件发布制品 安装Maven Artifact ChoiceListProvider (Nexus)插件, 可以使用该插件列出包列表。 

Nexus 06 使用Jenkins nexus 插件发布制品 Nexus 06 使用Jenkins nexus 插件发布制品

Nexus 06 使用Jenkins nexus 插件发布制品

Nexus 06 使用Jenkins nexus 插件发布制品

后面又上传了不同版本的制品,这里可以列出不同的版本,并且对其排序。

Nexus 06 使用Jenkins nexus 插件发布制品

 这个时候用户就可以去选择了,用户选择制品后, 拿到地址点击构建就可以拿到包的地址了。此时可以想象,Jenkins下载这个包, 然后通过salt、ansible进行发布部署。 

Nexus 06 使用Jenkins nexus 插件发布制品

String artifactURL = "${env.artifactUrl}".toString()pipeline {agent anystages {stage('Hello') {steps {println("The artifact url is: ${artifactURL}")sh "wget ${artifactURL} && ls"}}}
}

Nexus 06 使用Jenkins nexus 插件发布制品

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline (hide)
[Pipeline] node
Running on build-01 in /data/cicd/jenkinsagent/workspace/nexus/nexus-chajian-download
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Hello)
[Pipeline] echo
The artifact url is: http://139.198.166.235:8082/repository/devops-micro/org/devops/devops-lib/6.6.6/devops-lib-6.6.6.jar
[Pipeline] sh
+ wget http://139.198.166.235:8082/repository/devops-micro/org/devops/devops-lib/6.6.6/devops-lib-6.6.6.jar
--2021-11-25 09:10:48--  http://139.198.166.235:8082/repository/devops-micro/org/devops/devops-lib/6.6.6/devops-lib-6.6.6.jar
Connecting to 139.198.166.235:8082... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17063797 (16M) [application/java-archive]
Saving to: ‘devops-lib-6.6.6.jar’0K .......... .......... .......... .......... ..........  0%  286K 58s50K .......... .......... .......... .......... ..........  0%  395K 50s
....................................................................................16550K .......... .......... .......... .......... .......... 99%  264K 0s16600K .......... .......... .......... .......... .......... 99%  276K 0s16650K .......... ...                                        100%  502K=46s2021-11-25 09:11:35 (360 KB/s) - ‘devops-lib-6.6.6.jar’ saved [17063797/17063797]+ ls
devops-lib-6.6.6.jar
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

下载制品


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

Nexus 06 使用Jenkins nexus 插件发布制品

  相关解决方案