【问题标题】:How to deploy all the content in a folder to artifactory with similar folder structure through jenkins file如何通过jenkins文件将文件夹中的所有内容部署到具有相似文件夹结构的工件中
【发布时间】:2020-10-27 13:21:46
【问题描述】:

我们正在使用 artifactory 来存储我们的文件。位置${WORKSPACE}/build/processed/webApps/epmapp/*下的所有文件和文件夹都应该复制到下面提到的目标位置。

但只有文件被复制。

stage('Deploy Artifacts') 
        {
            def targetLocation="epmpbcs-release-local/Platform/PBCSVB/${BRANCH_NAME}/latest/"
            def targetLocationBuildNumber="epmpbcs-release/PBCSVB/${BRANCH_NAME}/${env.BUILD_NUMBER}/"
            stdout = sh(script: 'rm -fv ${WORKSPACE}/buildversion.txt',  returnStdout: true)
            println("Delete buildversion.txt stdout ################ " + stdout + " ####################")
 
            def buildversion = new File("${WORKSPACE}/buildversion.txt")
//            def w = buildversion.newWriter() 
            buildversion<<"PBCSVB Branch:${BRANCH_NAME}, Build Number:${BUILD_NUMBER}"
 
//
            def uploadSpec = """{
                "files": [
                        {
                          "pattern": "${WORKSPACE}/build/processed/webApps/epmapp/*",
                          "target" : "$targetLocation"
                        }
                 ]
                }"""

【问题讨论】:

    标签: jenkins jenkins-pipeline artifactory jenkins-groovy jfrog


    【解决方案1】:

    您不能一次上传文件和文件夹。这是上传部分工件的限制。 在上传工件之前,您需要再添加一项任务。 添加一个步骤以创建 .zip 或 .gzp 格式的“epmapp”文件夹,然后上传。

    def uploadSpec = """{
                "files": [
                        {
                          "pattern": "epmapp.zip",
                          "target" : "$targetLocation",
                          "recursive": "false"
                        }
                 ]
                }"""
    

    使用此link 了解更多信息。

    【讨论】: