gpt4 book ai didi

java - Jenkins/Artifactory-无法找到方法create()

转载 作者:行者123 更新时间:2023-12-03 06:02:55 25 4
gpt4 key购买 nike

我使用相同的gradle build脚本构建应用程序,将一些构建从Bamboo转移到jenkins。关闭人工项目后,构建成功,但是启用后失败:

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.

初始化脚本由 Artifact 插件创建,如下所示:
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

关于java - Jenkins/Artifactory-无法找到方法create(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40468802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com