How to prevent certain Jenkins missions from happening at the same time?

I have several tasks that use a shared resource (database), which can sometimes lead to a failure in a (rare) event when work tasks start at the same time.

If tasks from A to E are given, for example, is there a way to indicate that A and C should never run at the same time ?

In addition to the aforementioned resource, the assemblies are independent of each other (for example, in relation to the upstream / downstream).

The brute force method would limit the number of performers to one, but this would obviously be less ideal if most of the tasks could be performed at the same time, and there was no lack of computing resources on the build server.

+51
hudson jenkins
Jun 08 '11 at 8:45
source share
6 answers

There are currently 2 ways to do this:

+36
Mar 27 2018-12-12T00:
source share

The Locks and Latches plugin should help here .

This question is probably a hoax. How can I guarantee that only one of a certain category of tasks starts right away in Hudson?

+13
Jun 08 2018-11-11T00:
source share

Check out the External Resource Manager Jenkins plugin, which was first published in November 2012. This (relatively) new plugin seems to be exactly the cover this case.

+2
Jul 24. '13 at 14:26
source share

This is an old question, but the topic may be relevant, especially when running application tests on Jenkins.

Lockable Resources Plugin allows you to define blocked resources that can be used by assemblies. If a resource is required for the assembly, it blocks. If the second assembly requires the same resource (which is already locked), it will be queued so that the resource is free.

Although documents use computers or printers as examples of blocked resources, the sample database above should also work.

Unlike the Locks and Latches Plugin mentioned in the answers from 2012, this package seems to be currently supported (currently ~ 2016).

+1
Oct 18 '16 at 5:35
source share

NB you do not need physical or virtual equipment for the slave / node, you can configure the "slaves" that run on the main server.

Jenkins Management> Node Management> New node

and create "dumb subordinates," each with its own root directory.

Create several slaves, run them when the server boots up, and then create artist pools.

Perhaps you have, say ...

db is only one performer in your case. compile - restriction according to equipment or # processors. scripts - there are many performers for all those small tasks that Jenkins can do.

0
Jun 03 '14 at 13:38 on
source share

The old question is, and whether this will work for your application, I can not be sure, since you did not specify the details of your application. However, I wanted to add the way that I did this in our test suite of Rails applications.

The configuration of our application database.yml ( database.yml ) is not in the source repository. Instead, he lives in /var/lib/configs/uniquing_database.yml on the virtual machine that runs our Jenkins instance.

One of the steps in our build process is to copy this configuration file to the project workspace:

 cp /var/lib/jenkins/configs/myapp_unique_database.yml config/database.yml 

and this configuration takes the workspace and number information open to the Jenkins environment to create a unique database for this job and specific execution:

 test: adapter: postgresql encoding: unicode host: 127.0.0.1 port: 5432 database: myapp_test<%= ENV['JOB_NAME'].split('/').last %><%= ENV['BUILD_NUMBER'] %> 

The rest of our assembly continues without any knowledge or concern that it works in a separate database. Finally, at the end of our assembly, we will definitely delete this database so that we do not have a bunch of test databases polluting the file system:

 RAILS_ENV=test bundle exec rake db:drop 
0
Mar 08 '16 at 3:02
source share



All Articles