我尝试使用gradle将简单的zip上传到artifactory。这是我的剧本:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
}
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
def user = "$System.env.ARTIFACTORY_USER"
def pass = "$System.env.ARTIFACTORY_PASSWORD"
task createArchive(type: Zip){
baseName 'myzip'
destinationDir(new File('target'))
from '.'
exclude 'target'
exclude '.gradle'
exclude 'build.gradle'
exclude 'README.md'
doFirst{
new File('target').mkdirs()
}
}
task clean(type: Delete){
delete 'target'
}
publishing {
publications {
customArtifact(MavenPublication) {
artifact createArchive
}
}
}
artifactory {
publish {
contextUrl = 'http://myrepo/artifactory'
repository {
repoKey = "myrepo-tools"
username = user
password = pass
}
publications ('customArtifact')
}
}

代码似乎工作正常但实际上只发布了构建信息。拉链不是:
Deploying build descriptor to: http://myrepo/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://myrepo/artifactory/webapp/builds/myproject/1503338121156
我的代码与此处发布的代码似乎不同:How to build Groovy JAR w/ Gradle and publish it to in-house repo(在问题nothing published to artifactory using gradle artifactory plugin中被指向引用)但我不确定它是否仍然有效,因为它已经很老了
主要区别在于几乎所有示例都使用java插件,因此它们在出版物中有from components.java
行。在我的情况下,我不能使用它,因为我有自定义拉链..但我无法找到其他可以更改。
谢谢, 米歇尔。