Jenkins Artifactory插件在maven build

时间:2016-11-24 09:52:59

标签: maven jenkins jenkins-pipeline artifactory

我目前正在尝试使用神器Jenkins插件获取管道。当我在jenkins自由式项目中使用插件作为构建步骤时,它完美地运行。当我直接从管道中运行maven时,它完美地工作。当我使用下面的脚本通过Artifactory插件运行maven时,它失败了。我得到的错误是:

  

此环境中未提供编译器。也许你在跑步   在JRE上而不是JDK上?

这是我目前的剧本:

node {

    stage ('clone') {
        git credentialsId: 'git', url: '<URL to GIT repo>'
    }

    stage ('build and deploy') {
        env.JAVA_HOME="${tool 'JDK8'}"
        env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"

        def server = Artifactory.server "arti-test"
        def buildInfo = Artifactory.newBuildInfo()
        buildInfo.env.capture = true
        def rtMaven = Artifactory.newMavenBuild()
        rtMaven.tool = 'M3'
        rtMaven.resolver server: server, releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot'
        rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'

        rtMaven.run pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo

        buildInfo.retention maxBuilds: 10, maxDays: 7, deleteBuildArtifacts: true
        server.publishBuildInfo buildInfo
    }

}

1 个答案:

答案 0 :(得分:2)

Jenkins Artifactory插件的下一个版本将包含一个API,用于设置用于Maven和Gradle Pipeline构建的JDK。请参阅跟踪此任务的此问题: https://www.jfrog.com/jira/browse/HAP-848 作为临时解决方法,您可以将JDK / bin目录添加到Jenkins构建代理程序上的PATH环境变量中。您需要将其直接添加到代理计算机上(而不是通过Jenkine)。