Pipeline - Can it be triggered from a post-build action of a freestyle project?

Article ID:230922228
2 minute readKnowledge base

Issue

I have a Jenkins Pipeline which I am able to run by clicking Build. But when I try to start it from the Build other projects post-build action of an (freestyle) project, I just get an error in the form

my-flow is not buildable

and the downstream flow is not run when the upstream project is built.

Environment

  • Jenkins

  • CloudBees Jenkins Enterprise

  • Pipeline plugin

Resolution

The post-build action Build other projects does not simply do what it sounds like: build those projects when the step is run. In fact running the step does nothing at all. Instead, it causes the named projects to be included in an edge of the dependency graph, and downstream projects according to the graph are then run according to separate logic. And currently the dependency graph API is defined in such a way that Pipeline jobs cannot participate. Long story short, that mode does not work.

The Parameterized Trigger plugin offers other ways to start downstream jobs. The nonblocking trigger works much like the Jenkins core trigger: it affects the dependency graph. There is also a blocking trigger (which is a build step, not a post-build action), which just does what you probably expected: start the downstream build (much like the build step in Workflow). Currently this plugin does not support Pipeline, though it would probably be easy to make it use more current APIs so that it would: JENKINS-26050

What does work is to configure the relationship in the reverse direction: in the Pipeline job configuration, select Build after other projects are built and select your freestyle project. Now when the freestyle project finishes building, the Pipeline job is triggered.