通过jenins管道将构建的工件复制到新的git repo

时间:2019-11-04 13:24:48

标签: git automation jenkins-pipeline devops artifactory

我正在尝试在詹金斯管道上进行以下阶段的工作:

  1. 从Git存储库“ A”中获取代码
  2. 构建代码
  3. 将神器推入Artifactory
  4. 从Artifactory提取相同的工件(Zip文件格式)
  5. 将此Zip文件推送到新的git repo“ B”

我有第1-4步,但我不确定如何完成第5步。

任何帮助将不胜感激。

谢谢

我已经尝试了管道及其从步骤1到步骤4的正常工作。我通常将工件作为步骤5的一部分部署到应用程序/ Web服务器。这是一个新的场景,其中步骤5仅涉及将zip复制到新存储库中的特定目录。

//下面是第3和第4个工作阶段供参考

stage('Archive Artifacts'){
            steps{
                archiveIt(                                            
                   group: 'com.abc.www',
                   name: 'www-ui-app',
                   version: "${artVersion}",
                   repo: 'www-maven-release-local',
                   credentialsId: '************',
                   includePat: './dist/prod_build_archive/*.zip'
                )
            }
        }
        stage('Fetch Artifacts'){
           steps{
                withCredentials([usernamePassword(credentialsId: '************', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {

                sh "wget --user ${env.USERNAME} --password $PASSWORD --no-check-certificate \"https://rpo.int.net/artifactory/www-maven-release-local/com/abc/www/www-ui-app/${artVersion}/www_ui_app.zip\" "
                }
            }
        }
}

1 个答案:

答案 0 :(得分:1)

您可以使用Jenkins-Artifactory plugin分两个步骤完成操作:

  1. 使用rtUpload将工件上传到存储库“ A”。
  2. 使用rtPromote促进构建的存储库“ B”,并确保copy: true

可以找到一个示例here

或者,您可以使用JFrog CLI

相关问题