可以使用Artifactory插件将构建物在同一存储库中的不同路径之间复制吗?

huangapple go评论48阅读模式
英文:

Can we use the Artifactory plugin to copy artifacts between different paths within the same repository?

问题

背景:下游流水线执行构建并将构建产物存档到Artifactory的路径1。上游流水线(调用者)需要将下游的一些构建产物复制到一个单独的路径,以便与上游流水线的构建编号一起交付。当前的做法是下载构建产物然后上传它们,但我想知道是否可以在Artifactory中远程复制/移动它们,以避免网络流量。

我的问题:是否可以使用Artifactory插件在同一个Artifactory仓库内的不同路径之间复制构建产物?这是一个提醒,源路径和目标路径都在同一个Artifactory实例内。

然而,当我尝试使用Artifactory.server.copy时,我收到以下错误。看起来这个API根本不存在。

如果不可能,您有任何关于如何实现这一目标的想法吗?

英文:

The Background: The downstream pipelines do the builds and archive the artifacts to path-1 in Artifactory. The upstream pipeline (caller) needs to copy some artifacts of the downstream to a separate path for delivery with the upstream pipeline build num. The current practice is downloading the artifacts and uploading them but I wonder if I could remotely copy/move them in Artifactory to avoid web traffic.

My question: Is it possible to use the Artifactory plugin to copy artifacts between different paths within the same Artifactory repository? This a reminder that both the source and target paths are within the same Artifactory instance.

pipeline {
  agent any

  stages {
    stage('Copy Artifacts') {
      steps {
        script {
          // Set the source and target paths within the Artifactory repository
          def sourceRepo = 'libs-release-local'
          def sourcePath = 'path/to/source'
          def targetRepo = 'libs-release-local'
          def targetPath = 'path/to/target'

          // Copy the artifacts using the Artifactory plugin and capture build information
          def server = Artifactory.server('artifactory-server-id')
          def rtBuildInfo = Artifactory.newBuildInfo()
          server.copy {
            spec {
              fromRepo(sourceRepo)
              includePatterns(sourcePath + '/*')
              intoRepo(targetRepo)
              intoFolder(targetPath)
            }
            buildInfo rtBuildInfo
          }

          // Publish the captured build information to Artifactory
          server.publishBuildInfo(rtBuildInfo)
        }
      }
    }
  }
}

However, when I was trying to use Artifactory.server.copy, I got below error. Looks like this API doesn't exist at all.

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jfrog.hudson.pipeline.common.types.ArtifactoryServer.copy() is applicable for argument types: (org.jenkinsci.plugins.workflow.cps.CpsClosure2) values: [org.jenkinsci.plugins.workflow.cps.CpsClosure2@1712040b]
Possible solutions: any(), any(groovy.lang.Closure), notify(), wait(), every(), grep()

If is it impossible, do you have any ideas on how I could achieve that?

答案1

得分: 0

Jenkins Artifactory 插件 不支持此功能,但新的 Jenkins JFrog 插件 支持。新插件使安装和执行 JFrog CLI 命令变得简单。

在新插件中,您可以执行以下操作:

tools {
    jfrog 'jfrog-cli'
}

jf 'rt cp libs-release-local/path/to/source libs-release-local/path/to/target'

在此处阅读更多信息:

英文:

The Jenkins Artifactory plugin does not support this capability, however the new Jenkins JFrog plugin does. The new plugin makes it simple to install and perform JFrog CLI commands.

In the new plugin you could do the following:

tools {
    jfrog 'jfrog-cli'
}

jf 'rt cp libs-release-local/path/to/source libs-release-local/path/to/target'

Read more about it here:

huangapple
  • 本文由 发表于 2023年6月16日 10:08:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76486552.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定