代码之家  ›  专栏  ›  技术社区  ›  user3847894

在nexusArtifactUploader/Jenkinsfile中使用变量

  •  0
  • user3847894  · 技术社区  · 7 年前

    我有一个Jenkins DSL脚本,它的版本来自pom。xml文件,并在nexusArtifactUploader中使用该版本。这目前不起作用,我正在 “groovy.lang.MissingPropertyException:无此类属性:类的版本: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']
                            ]
                    )
                }
            }
        }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   bto    7 年前

    我认为你的错误其实在这一行:

    file: 'com.example-' + version + '.jar',
    

    尝试替换 version 具有 pom.version