-
pipeline里面的数据只能是字符串或者数字,其他不能被序列化的参数会报错
https://stackoverflow.com/questions/37864542/jenkins-pipeline-notserializableexception-groovy-json-internal-lazymap -
出现错误java.io.NotSerializableException
def getProject(projectName) {
def project = hudson.model.Hudson.instance.getItemByFullName(projectName)
if (!project) {error("Project not found: $projectName")}
return project
}
stage('Demo') {
project = getProject('add_build_info') //这一步会出错
def getUrl = project.lastBuild.getUrl()
println(getUrl)
}
- OK
def getProject(projectName) {
def project = hudson.model.Hudson.instance.getItemByFullName(projectName)
if (!project) {error("Project not found: $projectName")}
return project.lastBuild.getUrl()
}
stage('Demo') {
project = getProject('add_build_info')
println(project)
}