Jenkins + Gradle + Artifactory:无法读取生成的构建信息
Jenkins + Gradle + Artifactory: Couldn't read generated build info
我正在尝试使用调用 Gradle 工具的 Jenkins 管道将我的工件推送到 Artifactory。
我正在关注 GitHub 上发布的示例:
我的詹金斯管道脚本:
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 机器上,而不是我执行管道的奴隶。
感谢@tamir-hadad,它确实已经在 2.8.2 上修复了。
我正在尝试使用调用 Gradle 工具的 Jenkins 管道将我的工件推送到 Artifactory。
我正在关注 GitHub 上发布的示例:
我的詹金斯管道脚本:
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 机器上,而不是我执行管道的奴隶。
感谢@tamir-hadad,它确实已经在 2.8.2 上修复了。