Artifactory Gradle 仅部署插件 build.info

Artifactory Gradle Plugin deploys only build.info

我有一个 Gradle 插件,我想使用 Gradle Artifactory Plugin 将其部署到 Artifactory 服务器。

问题是 artifactoryDeploy 任务仅发布 build.info 元信息并跳过实际工件。您可以在日志中看到它。

> Task :artifactoryDeploy
Deploying build info...
Build-info successfully deployed. Browse it in Artifactory under http://my-company.artifactory.com/artifactory/webapp/builds/gradle-plugin/Thu%20Mar%2017%2017:07:21%20MSK%202022

BUILD SUCCESSFUL in 1s

这里是build.gradle。我做错了什么?

plugins {
    id 'java-gradle-plugin'
    id "com.jfrog.artifactory" version '4.27.1'
    id 'maven-publish'
    id 'com.gradle.plugin-publish' version '0.18.0'
}

gradlePlugin {
    plugins {
        somePlugin {
            id = 'com.example.gradle.plugin'
            displayName = 'Gradle Plugin'
            implementationClass = 'com.example.gradle.plugin.Plugin'
        }
    }
}

pluginBundle {
    website = 'https://company.gitlab.com/project'
    vcsUrl = 'https://company.gitlab.com/project'
    tags = ['plugin', 'codestyle', 'checkstyle', 'pmd']
}

publishing {
    publications {
        pluginPublication(MavenPublication) {
            from components.java
            groupId project.group
            artifactId 'my-plugin'
            version project.version
        }
    }
}

artifactory {
    contextUrl = 'http://my-company.artifactory.com'
    publish {
        repository {
            repoKey = 'gradle-plugins'
            username = project.properties['publishUser'] ?: 'user'
            password = project.properties['publishPassword'] ?: 'password'
        }
        defaults {
            publications(publishing.publications.names.toArray(String[]::new))
            publishBuildInfo = true
            publishArtifacts = true
            publishPom = true
            publishIvy = true
        }
    }
    // Redefine basic properties of the build info object
    def date = new Date().toString()
    clientConfig.setIncludeEnvVars(true)
    clientConfig.setEnvVarsExcludePatterns('*password*,*secret*')
    clientConfig.setEnvVarsIncludePatterns('*not-secret*')
    clientConfig.info.addEnvironmentProperty('test.adding.dynVar', date)
    clientConfig.info.setBuildName('MTS-Metric-Gradle-Plugin')
    clientConfig.info.setBuildNumber(date)
    clientConfig.timeout = 20
    clientConfig.setInsecureTls(true)
}

好的,我找到问题的根源了。您应该将 artifactoryDeploy 替换为 artifactoryPublish 命令。