【问题标题】:Gradle Artifactory deploy fails when using generated gradle.properties使用生成的 gradle.properties 时,Gradle Artifactory 部署失败
【发布时间】:2019-02-19 17:22:11
【问题描述】:

我有以下 build.gradle 文件:

plugins {
    id 'java-gradle-plugin'
    id 'com.gradle.plugin-publish' version '0.10.1'
    id 'groovy'
    id 'maven-publish'
    id "com.jfrog.artifactory" version "4.9.1"
}

group = 'de.gafertp'
version = '2.0.0'

repositories {
    mavenCentral()
}

dependencies {
    compile 'net.sourceforge.plantuml:plantuml:1.2019.1'

    testCompile 'org.junit.jupiter:junit-jupiter-api:5.4.0'
    testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
    testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
}

gradlePlugin {
    plugins {
        plantUmlPlugin {
            id = 'de.gafertp.plantuml'
            displayName = 'Gradle PlantUML Plugin'
            description = 'A very simple plugin to render PlantUML files. ' +
                    'Takes a set of diagram files together with desired output files / formats ' +
                    'and renders them with PlantUML (http://plantuml.com/).'
            implementationClass = 'de.gafertp.PlantUmlPlugin'
        }
    }
}

pluginBundle {
    website = 'https://github.com/codecholeric/gradle-plantuml-plugin'
    vcsUrl = 'https://github.com/codecholeric/gradle-plantuml-plugin'
    tags = ['plantuml']
}

publishing {
    publications {
        plantUmlPluginJar(MavenPublication) {
            from components.java
        }
    }
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'gradle-dev-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            println "username=${artifactory_user}"
            println "password=${artifactory_password}"
            maven = true
        }
        defaults {
            publications('plantUmlPluginJar')
        }
    }
    resolve {
        repository {
            repoKey = 'gradle-dev'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
    }
}

test {
    useJUnitPlatform()
}

还有这个 gradle.properties 文件:

artifactory_user=${security.getCurrentUsername()}
artifactory_password=${security.getEncryptedPassword()!"blahblah"}
artifactory_contextUrl=http://localhost:8081/artifactory

构建失败并出现以下错误:

Execution failed for task ':artifactoryDeploy'.
> java.io.IOException: Failed to deploy file. Status code: 401 Response message: Artifactory returned the following errors:
  Unauthorized Status code: 401

如果我们查看打印的用户名和密码,我们会看到:

username=${security.getCurrentUsername()}
password=${security.getEncryptedPassword()!"blahblah"}

Gradle 将属性值作为文字字符串而不是评估它们。所以问题似乎是找不到security对象,因为如果我直接将build.gradle文件中的属性替换为它们的值,就会出现以下错误:

A problem occurred evaluating root project 'gradle-plantuml-plugin'.
> Could not get unknown property 'security' for object of type org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper.

我做错了什么?使用纯文本用户名和密码时部署工作正常,但我想使用自动生成的登录方式(使用加密密码)。

【问题讨论】:

标签: gradle artifactory


【解决方案1】:

看来gradle.properties应该是这样的:

username=your_username
password=blahblah

我们假设blahblah 是您的加密密码。

【讨论】:

    猜你喜欢
    • 2015-01-24
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 2018-12-07
    • 2016-12-26
    相关资源
    最近更新 更多