目录
一、实验
1.Jenkins配置制品上传流水线
二、问题
1.上传制品显示名称有误
一、实验
1.Jenkins配置制品上传流水线
(1) 新建流水线项目
 (2)描述
(3)添加参数





(4)查看构建首页

(5)编辑流水线
@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")
                    sh "mvn clean package"
                }
            }
        }
        stage("UnitTest"){
            steps{
                script{
                    println("Test")
                    unittest.CodeTest("${env.buildTool}")
                }
            }
        }
        stage("Upload"){
            steps{
                script{
                    NexusUploadByPlugin("${env.artifactId}",
                            "target/maven-test-1.0-SNAPSHOT.jar",
                                        "${env.type}",
                                        "${env.groupId}",
                                        "${env.version}")
                }
            }
        }
    }
}
//NexusUploadByPlugin('devops-test','target/maven-test-1.0-SNAPSHOT.jar','jar','com.jenkins','1.1.2')
def NexusUploadByPlugin(artifactId,file,type,groupId,version ){
    nexusArtifactUploader artifacts: [[artifactId: artifactId,
                                       classifier: '',
                                       file: file,
                                       type: type]],
                          credentialsId: '318df1ad-083b-4158-ac88-2f584446563e',
                          groupId: groupId,
                          nexusUrl: '192.168.204.13:8081',
                          nexusVersion: 'nexus3',
                          protocol: 'http',
                          repository: 'mymavenrepo',
                          version: version
} 

(6)开始构建
(7)Blue Ocean查看

(8)查看日志

(9)Nexus查看

二、问题
1.上传制品显示名称有误
(1)报错

(2)原因分析
代码引用错误,使用了单引号
(3)解决方法
修改代码,使用双引号
修改前:
script{
                    NexusUploadByPlugin('${env.artifactId}',
                                        'target/maven-test-1.0-SNAPSHOT.jar',
                                        '${env.type}',
                                        '${env.groupId}',
                                        '${env.version}')
                } 
修改后:
script{
                    NexusUploadByPlugin("${env.artifactId}",
                            "target/maven-test-1.0-SNAPSHOT.jar",
                                        "${env.type}",
                                        "${env.groupId}",
                                        "${env.version}")
                } 
 
                


















![实用篇 | 3D建模中Blender软件的下载及使用[图文详情]](https://img-blog.csdnimg.cn/direct/74d038a46213492fadbd0a6f14dcbab9.png)