如何仅在 Jenkins 上为一个子模块执行包? [英] How to execute package for one submodule only on Jenkins?

查看:31
本文介绍了如何仅在 Jenkins 上为一个子模块执行包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 4 个模块的 sbt 项目:module-amodule-bmodule-cmodule-d.

I have a sbt project with 4 modules: module-a, module-b, module-c, module-d.

每个模块都可以打包成一个WAR.我想在 Jenkins 上设置一个部署,只构建 4 个模块中的一个并将其部署到容器中.

Each module can be packaged as a WAR. I want to set up a deployment on Jenkins that would build only one of the 4 modules and deploy it to a container.

详细来说,我想要 4 个 Jenkins 工作 - job-ajob-bjob-cjob-d,每次只构建定义好的模块(a到d).

In detail, I want to have 4 Jenkins jobs - job-a, job-b, job-c, job-d, each building only the defined module (a to d).

目前,我使用 clean update test package 作为 Jenkins sbt 构建的命令,但这会导致打包所有 4 个不必要的模块.

For now, I am using clean update test package as the command for the Jenkins sbt build, but this results in packaging all 4 modules that is not necessary.

我已经尝试过 project -module-a clean update test package 但没有成功.

I already tried project -module-a clean update test package but with no luck.

推荐答案

您可能还想执行项目范围的 cleantest 任务,如下所示:

You may also like to execute project-scoped clean and test tasks as follows:

sbt module-a/clean module-a/test

对于以下命令适用于什么项目,该解决方案略短且清晰.

The solution is slightly shorter and clearer as to what project the following commands apply to.

您不需要执行 update 任务,因为它是由 test 隐式执行的,如 inspect tree test 中所述.

You don't need to execute update task since it's implicitly executed by test as described in inspect tree test.

有一种方法可以使用别名使其更简洁.在 build.sbt 中使用以下内容:

There's a way to make it cleaner with an alias. Use the following in the build.sbt:

addCommandAlias("jenkinsJob4ModuleA", "; module-a/clean; module-a/test")

使用别名,执行jenkinsJob4ModuleA,效果和上面方案一样.

With the alias, execute jenkinsJob4ModuleA to have the same effect as the above solution.

这篇关于如何仅在 Jenkins 上为一个子模块执行包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆