我正在将一些构建从竹子转移到jenkins,使用相同的gradle构建脚本来构建应用程序。当artifactory关闭时,构建是成功的,但是当打开时,它失败了:
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')
您正在使用最新版本的Artifactory插件和build-info-extractor-gradle,但您的gradle版本是旧的。尝试使用最新版本gradle 3.1
如果您的评分脚本已经应用了"com.jfrog. "artifactory插件,然后在Jenkins作业中,你应该设置"项目使用artifactory插件"选项,以确保Jenkins不添加初始化脚本。对于Gradle的人工任务,Bamboo也有相同的复选框