Jenkins + Gradle + Artifactory:无法读取生成的构建信息

时间:2016-11-28 17:02:45

标签: jenkins gradle release artifactory jenkins-pipeline

我试图用Jenkins Pipeline将我的工件推送到Artifactory,这会调用Gradle工具。

我正在关注GitHub上发布的示例:

My Jenkins Pipeline脚本:

stage('Perform Gradle Release') {

    //ssh-agent required to perform GIT push (when tagging the branch on release)
    sshagent([git_credential]) {
        sh "./gradlew clean release unSnapshotVersion -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${release_version} -Prelease.newVersion=${development_version}"
    }

    // Create an Artifactory server instance
    def server = Artifactory.server('my-artifactory')

    // Create and set an Artifactory Gradle Build instance:
    def rtGradle = Artifactory.newGradleBuild()
    rtGradle.resolver server: server, repo: 'libs-release'
    rtGradle.deployer server: server, repo: 'libs-release-local'

    //Use Gradle Wrapper
    rtGradle.useWrapper = true

    //Creates buildinfo
    def buildInfo = Artifactory.newBuildInfo()
    buildInfo.env.capture = true
    buildInfo.env.filter.addInclude("*")

    // Run Gradle:
    rtGradle.run rootDir: "./", buildFile: 'build.gradle', tasks: 'clean artifactoryPublish', buildInfo: buildInfo

    // Publish the build-info to Artifactory:
    server.publishBuildInfo buildInfo

}

我的Gradle文件很轻,我只是使用插件Gradle Release Plugin来执行gradle版本。

执行管道时,它会失败并显示以下消息:

:artifactoryPublish

BUILD SUCCESSFUL

Total time: 17.451 secs
ERROR: Couldn't read generated build info at : /tmp/generated.build.info4898776990575217114.json
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.model.Run$RunnerAbortedException
    at org.jfrog.hudson.pipeline.Utils.getGeneratedBuildInfo(Utils.java:188)
    at org.jfrog.hudson.pipeline.steps.ArtifactoryGradleBuild$Execution.run(ArtifactoryGradleBuild.java:127)
    at org.jfrog.hudson.pipeline.steps.ArtifactoryGradleBuild$Execution.run(ArtifactoryGradleBuild.java:96)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:40)
...
Finished: FAILURE

当我检查服务器时,没有这样的文件/tmp/generated.build.info4898776990575217114.json(用户当然有权写入/ tmp)。

感谢您的帮助。

[编辑]这很奇怪,但我找到了一些名为" buildInfo2408849984051060030.properties"的文件,其中包含了这些信息。名称不一样,格式也不一样,这些文件是我的Jenkins机器上的存储,而不是我的从机执行管道。

1 个答案:

答案 0 :(得分:0)

谢谢@ tamir-hadad,确实已经修复了2.8.2。