简体   繁体   English

从Jenkins将多个Gradle工件上传到Artifactory

[英]Upload multiple Gradle artifacts to Artifactory from Jenkins

My environment uses Gradle for builds, Jenkins for CI, and Artifactory for a repository. 我的环境将Gradle用于构建,将Jenkins用于CI,将Artifactory用于存储库。 I use the Artifactory plugin for Jenkins. 我将Artifactory插件用于Jenkins。

Jenkins successfully builds my main jar file and uploads it to Artifactory. Jenkins成功构建了我的主jar文件,并将其上传到Artifactory。 The build script has a second target for creating a distribution zip file under build/distributions. 构建脚本还有第二个目标,用于在构建/分发下创建分发zip文件。 Jenkins creates the zip file successfully, but I don't know how to tell it to upload that artifact to Artifactory, too. Jenkins成功创建了zip文件,但是我也不知道如何告诉它将该工件上传到Artifactory。

Is this something I should be able to specify in the Jenkins Artifactory plugin config, or something I should define in the Gradle build script? 这是我应该可以在Jenkins Artifactory插件配置中指定的东西,还是应该在Gradle构建脚本中定义的东西? Thanks for any pointers. 感谢您的指导。

You should configure the archives configuration to include all the archives you intend to publish as described in Gradle's user manual . 您应该配置archives配置,以包括您打算按照Gradle的用户手册中所述发布的所有存档。 Not only Artifactory will pick up all the files to deploy automatically (without messing with Published Artifacts configuration), you won't even need to run the second task. Artifactory不仅会拾取所有文件以进行自动部署(不会与Published Artifacts配置发生冲突 ),您甚至不需要运行第二个任务。 All the archives will be creating by running the build task. 通过运行build任务将创建所有档案。

I assume you have configured artifactory server correctly in Manage Jenkins section; 我假设您在Manage Jenkins部分中正确配置了工件服务器; also your job is setup as a Freestyle Project . 您的工作也被设置为Freestyle项目

Select your job and click Configure . 选择您的工作,然后单击配置 Check Generic Artifactory Integration in Build Environment . 构建环境中检查通用人工工厂集成 Select your Artifactory Server and Target Repository from drop downs, check Override default deployer credentials if required. 从下拉列表中选择您的Artifactory Server目标存储库 ,如果需要,请选中“ 覆盖默认的部署者凭证” In Published Artifacts you enter the pattern for your zip file to be published, eg ${WORKSPACE}/distr/*.zip (where by WORKSPACE is jenkins current project's workspace and distr/*.zip your distribution zip file). 发布的工件中 ,输入要发布的zip文件的模式,例如${WORKSPACE}/distr/*.zip (其中WORKSPACE是jenkins当前项目的工作区,而distr / *。zip是您的分发zip文件)。 Check if required Capture and publish build info , Include environment variables etc. Save your job. 检查是否需要捕获并发布构建信息包括环境变量等。保存您的工作。 When you build it the next time, the zip file will be uploaded and will be available in the Builds section on artifactory. 下次生成该zip文件时,该zip文件将被上传,并且可以在工件上的Builds部分中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM