使用Grail的gradlew和用户的gradle.properties文件发布到Artifactory

时间:2016-04-18 16:55:34

标签: grails gradle

我尝试使用项目的Gradle包装器和键入用户gradle.properties的凭据发布到Artifactory。

在我的build.gradle文件中,我有以下代码段要发布到Artifactory

artifactory {
    contextUrl = "https://path.to/artifactory"
    publish {
        repository {
            repoKey = 'plugins-release-local'
            username = ${artifactory_user}
            password = ${artifactory_password}
            maven = true

        }
        defaults {
            publications ('mavenJava')
        }
    }
}

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

以下是我的gradle.properties文件的内容:

me@workstation ~/.gradle
$ cat gradle.properties
artifactory_user=xxx
artifactory_password=yyy

使用build.gradle中的用户名和密码进行硬编码,这有效:

./gradlew artifactoryPublish

尝试阅读~/.gradle/gradle.properties

./gradlew artifactoryPublish
HTTP response code: 502. HTTP response message: Bad Gateway

尝试通过CLI传递凭据时:

./gradlew -Dartifactory_user=xxx -Dartifactory_password=yyy artifactoryPublish
HTTP response code: 401. HTTP response message: Unauthorized

更新#1

每个@RaGe更新build.gradle:

artifactory {
    contextUrl = "https://path/to/artifactory"
    publish {
        repository {
            repoKey = 'plugins-release-local'
            username = artifactory_user
            password = artifactory_password
            maven = true

        }
        defaults {
            publications ('mavenJava')
        }
    }
}

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

结果:使用:

获得401而不是502
  • ./ gradlew artifactoryPublish
  • ./ gradlew -Dartifactory_user = xxx -Dartifactory_password = yyy artifactoryPublish

更新#2

Artifactory在Tomcat8 / Java8上运行,通过Apache 2.2上的反向代理访问。

更新#3

注意解决方案:在Cygwin下,确保编辑右侧gradle.properties,位于C:\ Users \ username.gradle \ gradle.properties

1 个答案:

答案 0 :(得分:1)

看起来像语法问题。删除变量周围的${}

username = artifactory_user
password = artifactory_password