Gradle 为多个工件控制发布到Artifactory(如果已经发布,则跳过)

Gradle 为多个工件控制发布到Artifactory(如果已经发布,则跳过),gradle,artifactory,Gradle,Artifactory,我的项目中有一个动态生成的出版物列表。 我想问一下,如果其中一种出版物出现错误,是否有一种方法可以对每种出版物进行一次尝试,然后继续。 原因是不是所有的版本都是递增的,它们也不应该是递增的,所以我只想推送那些尚未存在的版本。 我想在发布阶段或者在动态生成发布时这样做 假设我有一个任务publish_1,publish_2,publish_3 我想确保即使publish_1和publish_2失败,publish_3仍然会发生 我想要控制失败的原因是文件是否已经发布。 另一个选择是,我可以在查询a

我的项目中有一个动态生成的出版物列表。 我想问一下,如果其中一种出版物出现错误,是否有一种方法可以对每种出版物进行一次尝试,然后继续。 原因是不是所有的版本都是递增的,它们也不应该是递增的,所以我只想推送那些尚未存在的版本。 我想在发布阶段或者在动态生成发布时这样做

假设我有一个任务publish_1,publish_2,publish_3 我想确保即使publish_1和publish_2失败,publish_3仍然会发生

我想要控制失败的原因是文件是否已经发布。 另一个选择是,我可以在查询artifactory之前查看文件是否存在(不知道如何做)

这是我出版的一个想法,是这样的:

HashMap<String,ProtoFile> artifacts = new HashMap<String,ProtoFile>()
List<String> thePublications = new ArrayList<String>()

publishing {
  artifacts.values().each() { f ->
    def pubName = "publish_"+f.name
    publications.create(pubName, MavenPublication) {
      groupId = f.groupId
      artifactId = f.artifactId
      version = f.version
      artifact(file("build/distributions/" + f.zipFileName))
      thePublications.add(pubName)
    }
  }
}

    deploy {
      publications thePublications.toArray(new String[thePublications.size()])
    }
HashMap artifacts=newhashmap()
列出publications=new ArrayList()
出版{
artifacts.values().each(){f->
def pubName=“发布”+f.name
publications.create(pubName、MavenPublication){
groupId=f.groupId
artifactId=f.artifactId
版本=f.version
工件(文件(“build/distributions/”+f.zipFileName))
Publications.add(pubName)
}
}
}
部署{
publications-thePublications.toArray(新字符串[thePublications.size()])
}

我没有完全得到我想要的,所以我会让它保持打开状态,但最终找到了一种方法,只需检查artfiactory中是否存在该文件即可

def addPublication(publicationName, fileProperties, artifactoryPublications) {
  final String artifactBaseUrl = 'https://your.repo.here/artifactory'
  final String artifactFile = fileProperties.artifactGroupUrl + '/' + fileProperties.artifactId + '/' + fileProperties.version + '/' +  fileProperties.zipFileName

  Artifactory artifactory = ArtifactoryClientBuilder.create()
          .setUrl(artifactBaseUrl)
          .build()

  ItemHandle result = artifactory.repository('/local-m2-development/').file(artifactFile)

  try {
    result.info();
    println fileProperties.zipFileName + " is being skipped because it's already in artifactory with version " + fileProperties.version
  } catch(Exception e) {
    artifactoryPublications.add(publicationName)
  }
}