jenkins - 部署由另一个作业构建的 Jenkins 工件

标签 jenkins continuous-deployment

我安装了Deploy Plugin在我的 Jenkins 上,以便自动将我的 Maven 构建的 war 包部署到 Tomcat 7。问题是,只有当它们是在使用部署插件的同一作业中进行时,我才能使用该插件部署到远程 Tomcat 服务器。换句话说,我无法设置一个独立的作业来部署由不同作业制作的工件。

例如,我有一个名为 pack.foo 的作业。它使用/var/lib/project/module中的源代码创建module.war并将其放入/var/lib/project/module/target中。但是,由于 Maven 版本设置的原因,pack.foo 的工件页面上发布的工件类似于 module-2.0.0-SNAPSHOT.war

我能够部署 module.war 的唯一方法是向 pack.foo 添加一个 Post-build Action 并将 **/module.war 指定为远程 Tomcat 管理器 URL (前提是我在 Jenkins 配置中有经理的凭据)。然后作业的控制台输出记录/var/lib/project/module/target/module.war 已部署到该 URL:

Deploying /var/lib/project/module/target/module.war to container Tomcat 7.x Remote with context 
  [/var/lib/project/module/target/module.war] is not deployed. Doing a fresh deployment.
  Deploying [/var/lib/project/module/target/module.war]

我如何使用这个或另一个插件来部署在单独的 Jenkins 作业中制作的 WAR 工件?我希望有单独的工作来创建和部署工件。该插件没有找到 **/module-2.0.0-SNAPSHOT.war 甚至找不到由另一个作业构建的 **/module.war,即使磁盘上肯定有一个与该模式匹配的文件。

最佳答案

请参阅 Deploy Plugin's page 上的段落您链接:

How to rollback or redeploy a previous build

There may be several ways to accomplish this, but here is one suggested method:

  1. Install the Copy Artifact Plugin
  2. Create a new job that you will trigger manually only when needed
  3. Configure this job with a build parameter of type "Build selector for Copy Artifact", and a copy artifact build step using "Specified by build parameter" to select the build.
  4. Add a post-build action to deploy the artifact that was copied from the other job

Now when you trigger this job you can enter the build number (or use any other available selector) to select which build to redeploy. Thanks to Helge Taubert for this idea.

关于jenkins - 部署由另一个作业构建的 Jenkins 工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47296544/

相关文章:

java - 包包含具有相同名称的对象和包

xml - 需要 XSL 文件将内部 xml 测试格式转换为 Junit 格式(jenkins 的 xUnit 插件)

continuous-integration - 手 Action 业中的 Gitlab CI/CD 预填充变量

jenkins - 使用 jenkins 远程 glassfish 部署失败

git - 如何持续部署 : VisualStudio. com 的 tfs Git -> Heroku

jenkins - 将Docker镜像推送到Jenkinsfile中的注册表时出错

git - Jenkins GitHub 插件无法选择我的凭据

jenkins - junit 插件未显示 jenkins 中所有测试的结果

github - 如何为多部署配置只执行一次 Travis CI 'before_deploy' 步骤?

kubernetes - ArgoCD app-of-apps 创建子应用程序但不在应用程序内部署 list