【发布时间】:2023-03-31 16:40:01
【问题描述】:
我有这个 Jenkins DSL 脚本,它从 pom.xml 文件中获取版本并在 nexusArtifactUploader 中使用该版本。这目前不起作用,我收到 "groovy.lang.MissingPropertyException: No such property: version for class: groovy.lang.Binding" 错误。我是 Groovy/Jenkins DSL 的新手,不知道如何让它工作。
stage('Nexus') {
steps {
script {
def pom = readMavenPom file: 'pom.xml'
echo pom.version
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: 'nexus.example.com:8080/nexus',
groupId: 'com.example',
**version: "${pom.version}",**
repository: 'example',
credentialsId: 'ciuser',
artifacts: [
[artifactId: 'com.example',
file: 'com.example-' + version + '.jar',
type: 'jar']
]
)
}
}
}
【问题讨论】:
标签: jenkins groovy jenkins-plugins jenkins-pipeline