目录

持续集成交付CICD:使用Jenkins插件上传Nexus制品

目录

一、实验

1.使用Jenkins插件上传Nexus制品


一、实验

1.使用Jenkins插件上传Nexus制品

(1)Jenkins安装插件Nexus Artifact Uploader

(2)添加凭据

(3)使用片段生成器生成DSL

(4)生成流水线脚本

bash 复制代码
nexusArtifactUploader artifacts: [[artifactId: 'devopstest', classifier: '', file: 'target/maven-test-1.0-SNAPSHOT.jar', type: 'jar']],
credentialsId: '318df1ad-083b-4158-ac88-2f584446563e',
groupId: 'com.jenkins',
nexusUrl: '192.168.204.13:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'mymavenrepo',
version: '1.1.2'

(5)Jenkins流水线直接修改回放,点击运行

bash 复制代码
@Library("mylib@master") _
import org.devops.*


def checkout = new 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")
                    checkout.GetCode("${env.srcUrl}","${env.branchName}")
                }
            }
        }
        stage("build"){
            steps{
                script{
                    println("Build")
                    build.CodeBuild("${env.buildTool}")
                }
            }

        }

        stage("UnitTest"){
            steps{
                script{
                    println("Test")
                    unittest.CodeTest("${env.buildTool}")
                }
            }

        }
        stage("SonarScan"){
            steps {
               script {
                    groupName = "${JOB_NAME}".split("/")[0]
                    projectName ="${JOB_NAME}".split("/")[-1]
                    sonar.CodeSonar("${env.buildTool}",projectName,groupName)
                    
                    nexusArtifactUploader artifacts: [[artifactId: 'devopstest', classifier: '', file: 'target/maven-test-1.0-SNAPSHOT.jar', type: 'jar']], 
                                          credentialsId: '318df1ad-083b-4158-ac88-2f584446563e', 
                                          groupId: 'com.jenkins', 
                                          nexusUrl: '192.168.204.13:8081', 
                                          nexusVersion: 'nexus3', 
                                          protocol: 'http', 
                                          repository: 'mymavenrepo', 
                                          version: '1.1.2'
                }

            }

        }

    }

}

(6)Blue Ocean查看

(7)查看日志,显示已成功上传制品

(8)Nexus查看

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
BUG 劝退师3 小时前
进程间通讯(IPC)
运维·服务器·网络
桥边驿语人5 小时前
使用Docker Desktop进行本地打包和推送
运维·docker·容器·本地打包
头发尚存的猿小二6 小时前
Linux--文件系统
linux·运维·服务器
程序辕日记7 小时前
使用SQL查询ES数据
sql·elasticsearch·jenkins
是程序喵呀7 小时前
软考《信息系统运行管理员》- 7.1 物联网运维
运维·物联网·软考
卑微的小鬼7 小时前
fabric test-network启动
运维·fabric
sondx8 小时前
mac安装浏览器闪退处理
运维·docker·容器
Liuzhengyue_8 小时前
Linux shell脚本编程
linux·运维·服务器
啥都不懂的小小白8 小时前
Elasticsearch入门指南(三) 之 高级篇
大数据·elasticsearch·jenkins
babytiger8 小时前
在 VMware 中为 Ubuntu 24.04 虚拟机设置共享文件夹后,在虚拟机中未能看到共享的内容
linux·运维·ubuntu