Jenkins/Artifactory - 找不到方法 create()
Jenkins/Artifactory - Unable to find method create()
我正在将一些构建从 bamboo 转移到 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作业中你应该设置"Project uses the Artifactory plugin"选项,以确保Jenkins不添加初始化脚本。 Bamboo 对 Gradle Artifactory 任务具有相同的复选框。
我正在将一些构建从 bamboo 转移到 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作业中你应该设置"Project uses the Artifactory plugin"选项,以确保Jenkins不添加初始化脚本。 Bamboo 对 Gradle Artifactory 任务具有相同的复选框。