我正在将一些构建从竹子转移到jenkins,使用相同的gradle构建脚本来构建应用程序。关闭神器后,构建成功,但启动时失败并显示:
09:22:08.568 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
09:22:08.569 [ERROR] [org.gradle.BuildExceptionReporter]
09:22:08.569 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
09:22:08.569 [ERROR] [org.gradle.BuildExceptionReporter] Initialization script '/tmp/init-artifactory2218166479825929225gradle' line: 20
09:22:08.570 [ERROR] [org.gradle.BuildExceptionReporter]
09:22:08.570 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
09:22:08.570 [ERROR] [org.gradle.BuildExceptionReporter] Failed to notify build listener.
09:22:08.570 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to notify build listener.
09:22:08.571 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find method create() for arguments [artifactoryPublish, class org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask] on task set.
初始化脚本由artifactory插件创建,如下所示:
import org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
initscript {
dependencies {
classpath fileTree('/var/lib/jenkins/cache/artifactory-plugin/2.7.2')
}
}
addListener(new BuildInfoPluginListener())
class BuildInfoPluginListener extends BuildAdapter {
def void projectsLoaded(Gradle gradle) {
gradle.startParameter.getProjectProperties().put("build.start", Long.toString(System.currentTimeMillis()))
Project root = gradle.getRootProject()
root.logger.debug("Artifactory plugin: projectsEvaluated: ${root.name}")
if (!"buildSrc".equals(root.name)) {
root.allprojects {
apply {
apply plugin: ArtifactoryPlugin
}
}
}
// Set the "archives" configuration to all Artifactory tasks.
for (Project p : root.getAllprojects()) {
Task t = p.getTasks().findByName(ArtifactoryTask.BUILD_INFO_TASK_NAME)
if (t != null) {
ArtifactoryTask task = (ArtifactoryTask)t
task.setAddArchivesConfigToTask(true)
}
}
}
}
我们正在为此项目使用gradle 1.5,该版本已在build.gradle中声明。
的build.gradle:
apply plugin: 'groovy'
apply from: 'scripts/wrapper.gradle'
gradleVersion='1.5'
group = 'com.company.build'
task testBuildSingle(type: GradleBuild) {
buildFile = 'test/single/build.gradle'
tasks = ['clean', 'build']
}
task testBuildMulti(type: GradleBuild) {
buildFile = 'test/multi/build.gradle'
tasks = ['clean', 'build']
}
test.dependsOn('testBuildSingle')
task dist(type: Copy) {
from 'scripts'
into("$buildDir/scripts")
eachFile({
def file = file("scripts/${it.getPath()}")
println file
artifacts.add('archives', file)
})
}
dist.dependsOn('test')
答案 0 :(得分:0)
您使用的是最新版本的Artifactory插件和build-info-extractor-gradle,但您的gradle版本已经过时了。尝试使用最新版本的gradle 3.1
答案 1 :(得分:0)
如果您的成绩脚本已经应用了" com.jfrog.artifactory"插件,然后在Jenkins工作中你应该设置" Project使用Artifactory插件"选项,以确保Jenkins不添加初始化脚本。 Bamboo具有与Gradle Artifactory任务相同的复选框。