持续集成交付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查看

相关推荐
考虑考虑1 小时前
nginx路由重写
运维·后端·自动化运维
Zenova EdgeOS3 小时前
Linux 内核日志 dmesg 进阶实战:从现场过滤到持久化闭环
linux·运维·服务器
郝亚军4 小时前
ec_private.pem的生成方法
linux·运维·服务器
NendoZen4 小时前
Arch Linux解决Grub无法SAVEDEFAULT问题(uki启动问题)
linux·运维·服务器
Elastic 中国社区官方博客5 小时前
Elasticsearch:安装自行管理的 Elastic Stack 集群
大数据·运维·服务器·数据库·elasticsearch·搜索引擎·全文检索
忆挽篱笙歌5 小时前
进程控制管理
linux·运维·服务器
fengkai45457 小时前
3、Kubernetes的Namespace&Contexts&Pod&YAML格式
运维·容器·kubernetes·k8s·namespace·yaml·pod
戴西软件7 小时前
制造研发中的AI视觉与仿真:戴西工程图纸智能审图智能体、戴西3DViz_CAE AI集成与戴西3DViz_CAD AI集成
大数据·运维·人工智能·3d·自动化·制造·rpa
javaDocker8 小时前
1800 亿科技投入砸下去,多数机构平的只是服务器,不是能力
运维·服务器·人工智能·科技·研发效能·金融科技
骇客野人8 小时前
Linux 全套实操方案(含目录详解、文件传输、日志、文件规范、环境变量、Java 应用部署运维)
java·linux·运维