1

I have configured a multibranch-pipeline project in Jenkins. This project run integration test on all my feature branches (git). For each job in the pipeline project it creates an instance of my webapp (start tomcat and other dependencies). Because of port binding issues this result in many broken jobs.

Can I throttle the builds in the multibranch-pipeline project, so that the jobs for each feature branch run sequentially instead of parallel?

Or if there any more elegant solution?


Edit: Situation and problem:

  • I want to have a multibranch pipeline project in Jenkins (because I have many feature branches in git)
  • The jobs which are created from the multibranch pipeline (for each feature branch in git), run in parallel
    • Polling scm is at midnight (commits on x branches are new, so the related jobs started at midnight)
  • every job started one instance of my webapp (and other dependencies) which bind to some ports

The problem is, that there can start many of these jobs at midnight. Every job will try to start an instance of my webapp. The first job can start the webapp without any problem. The second job cannot start the webapp because the ports are already taken from the first instance.

I don't want to configure a new port binding for each feature branch in my git repository. I need a solution to throttle the builds in the multibranch pipeline, so that only on "feature" can run concurrently.

Cayacdev
  • 25
  • 8

2 Answers2

1

From what I've read in other answers the disableConcurrentBuilds command only prevents multiple builds on the same branch.

If you want only one build running at a time, period, go to your Nodes/Build Executor configuration for the specific VM that your app is running on, drop the number of executors to 1 and configure the node labels so that only jobs from your multibranch pipeline can run on that VM.

My project has strict memory, licensing and storage constraints, so with this setup, all the jobs on the master and feature branches start, but only one can run at a time until the executor becomes available.

ESPeach
  • 311
  • 3
  • 9
0

The most elegant solution would be to make your Integration Tests to be able to run concurrently.

One solution would be to use an embedded tomcat with a dynamic port. In that way each job instance would run in tomcat with different ports. This is also a better solution than relying on an external server.

If this is too much work, you can always use the following code in your "jenkinsfile" pipeline:

node {
  // This limits build concurrency to 1 per branch
  properties([disableConcurrentBuilds()])

  // continue your pipeline ... 

}

The solution comes from this SO answer.

рüффп
  • 5,172
  • 34
  • 67
  • 113