简体   繁体   English

如何在詹金斯建立一个工作流程?

[英]How to build a pipeline of jobs in Jenkins?

In my project, I have 3 web-applications, all depend on one all-commons project. 在我的项目中,我有3个web应用程序,都依赖于一个all-commons项目。

In my Jenkins server, I built 4 jobs, all-commons_RELEASE , web-A_RELEASE , web-B_RELEASE and web-C_RELEASE . 在我的Jenkins服务器中,我构建了4个作业, all-commons_RELEASEweb-A_RELEASEweb-B_RELEASEweb-C_RELEASE The role of these jobs is to build the artifacts, which are deployed on our Nexus. 这些工作的作用是构建部署在Nexus上的工件。 Then, someone retrieve these artifacts in Nexus and deploy them on our dev / homologation servers. 然后,有人在Nexus中检索这些工件并将它们部署在我们的开发/认证服务器上。

What I want, is to have one (additional?) job that will launch all the 4 builds, in a sequential way. 我想要的是,有一个(额外的?)工作将按顺序启动所有4个版本。 This way, once this job is finished, all the RELEASE jobs have been executed. 这样,一旦完成此作业,所有RELEASE作业都已执行。 Of course, if one build fails, the process is stopped. 当然,如果一个构建失败,则该过程停止。

My first thought was to indicate the web-A_RELEASE in the Build other projects list of the Post-build Actions of all-commons_RELEASE . 我的第一个想法是在all-commons_RELEASEPost-build ActionsBuild other projects列表中指出web-A_RELEASE all-commons_RELEASE Then, web-B_RELEASE is dependent on web-A_RELEASE , and so on. 然后, web-B_RELEASE依赖于web-A_RELEASE ,依此类推。

However, I want to be able to start any of them separately, which is not possible if I indicate a dependency on the projects. 但是,我希望能够单独启动它们,如果我指出对项目的依赖性,这是不可能的。 For example, if I manually start web-B_RELEASE , then web-C_RELEASE will be built after that, which is not what I want... 例如,如果我手动启动web-B_RELEASE ,那么之后将构建web-C_RELEASE ,这不是我想要的......

Do you have any idea how I can achieve that, or a plugin to help me to do that? 你知道我怎么能做到这一点,或者一个插件来帮助我做到这一点?

Regards. 问候。

ps: Jenkins 1.430, and all RELEASE jobs are free-style projects (they mix Maven and bash commands). ps:Jenkins 1.430,所有RELEASE作业都是自由式项目(它们混合了Maven和bash命令)。

Perhaps you could use the Parametrized Trigger Plugin ? 也许您可以使用参数化触发插件

Using the plugin you can set the trigger as a build step in your "Pipeline" Job. 使用该插件,您可以将触发器设置为“管道”作业中的构建步骤。 There is a checkbox "Block until triggered job is finished", which you need to activate. 有一个复选框“阻止直到触发的作业完成”,您需要激活该复选框。 You could simply configure your three jobs to be triggered this way, and the triggering would only occur if you run this new Pipeline Job, so running the other jobs without triggering anything would work fine. 您可以简单地将这三个作业配置为以这种方式触发,并且只有在运行此新管道作业时才会触发,因此运行其他作业而不触发任何操作都可以正常工作。

This should be exactly what you need. 这应该是你需要的。

Don't know if you've found your answer yet, but for others who are curious: 不知道你是否已找到答案,但对于其他好奇的人:

You can create another job build_all , and then have each of the other builds triggered as build steps. 您可以创建另一个作业build_all ,然后将每个其他构建作为构建步骤触发。

The setup you'd want would look like this for build_all , with each build step being "Trigger/Call builds on other projects" 您想要的设置对于build_all看起来像这样,每个构建步骤都是“在其他项目上触发/调用构建”

  • Build Step 1 : all-commons_RELEASE 构建第1步:all-commons_RELEASE
  • Build Step 2 : web-A_RELEASE 构建第2步:web-A_RELEASE
  • Build Step 3 : web-B_RELEASE 构建第3步:web-B_RELEASE
  • Build Step 4 : web-C_RELEASE 构建第4步:web-C_RELEASE

Make sure you check the "Block until the triggered projects finish their builds" option to ensure the builds happen sequentially. 确保选中“阻止直到触发的项目完成其构建”选项,以确保构建按顺序发生。

Try this 试试这个

Build Flow plugin Build Flow插件

you can sequentially run or build your job like this : 你可以按顺序运行或构建你的工作:

build("job1")
build("job2")
.
.
build("job-n")

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

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