繁体   English   中英

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

[英]Jenkins/Artifactory - Unable to find method create()

我使用相同的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.

初始化脚本由工件插件创建,如下所示:

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 using Artifactory plugin”选项,以确保Jenkins不添加初始化脚本。 Bamboo对Gradle Artifactory任务具有相同的复选框。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM