How to build a pipeline of jobs in Jenkins?

2019-04-09 20:12发布

In my project, I have 3 web-applications, all depend on one all-commons project.

In my Jenkins server, I built 4 jobs, all-commons_RELEASE, web-A_RELEASE, web-B_RELEASE and web-C_RELEASE. The role of these jobs is to build the artifacts, which are deployed on our Nexus. Then, someone retrieve these artifacts in Nexus and deploy them on our dev / homologation servers.

What I want, is to have one (additional?) job that will launch all the 4 builds, in a sequential way. This way, once this job is finished, all the RELEASE jobs have been executed. 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. Then, web-B_RELEASE is dependent on web-A_RELEASE, and so on.

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...

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).

3条回答
太酷不给撩
2楼-- · 2019-04-09 20:26

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.

The setup you'd want would look like this for build_all, with each build step being "Trigger/Call builds on other projects"

  • Build Step 1 : all-commons_RELEASE
  • Build Step 2 : web-A_RELEASE
  • Build Step 3 : web-B_RELEASE
  • Build Step 4 : web-C_RELEASE

Make sure you check the "Block until the triggered projects finish their builds" option to ensure the builds happen sequentially.

查看更多
【Aperson】
3楼-- · 2019-04-09 20:29

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.

查看更多
何必那么认真
4楼-- · 2019-04-09 20:31

Try this

Build Flow plugin

you can sequentially run or build your job like this :

build("job1")
build("job2")
.
.
build("job-n")
查看更多
登录 后发表回答