Shared resource locks can be specified at configuration or stage level. At configuration level, the build will sit in a queue until the lock can be acquired and the lock will be released when the build finishes. At stage level, the build stage will sit in a queue before reserving an agent until a lock can be acquired and the lock will be released when the stage execution finishes. 

Configuration Shared Resource Locks

Configurations can be setup to require and acquire locks on Server Shared Resources while evaluating configuration conditions before starting each build. The number and types of locks required are specified in the Conditions step of the Configuration Wizard.

Add a new condition, select the "Queue" behaviour and then select the "Shared resource lock" condition type. Note that shared resource lock can only be added to queue conditions, builds can not be discarded based on shared resource locks.



Choose an existing shared resource Identifier. Only server shared resources can be selected for a configuration, locks on agent shared resources are configured on a stage - see next section on Stage Shared Resource Locks. The additional fields depend on the type of shared resource

No further details are required for a lock on a Single shared resource as shown below: 



With Quota shared resources, you can specify the type of Lock: Read or Write. If you choose to acquire a Read lock then you can enter the Number of locks required from the allocated quota.



Likewise with Infinite shared resources.


Quota list shared resources have several more options. You can choose an Operation. The choices are as follows:  

You can also select the type of Lock: Read or Write. If you choose to acquire a Read lock then you can enter the Number of locks required from the allocated quota of a label. 

You can add or remove rows using + and - buttons at the end of each row. If multiple shared resource locks are defined, the build will sit in the queue until all locks are acquired.


Stage Shared Resource Locks

Stages can be setup to require and acquire locks on Server Shared Resources before selecting an agent and Agent Shared Resources while selecting an agent. The number and types of locks required are specified on the Shared Resource Locks tab of the Stage Options dialog.

The fields depend on the type of shared resource selected as with Configuration Shared Resource Locks as described above. 

When a stage is queued, Continua CI will first attempt to acquire any server shared resources. Once these are acquired, the system will attempt to find an available and compatible agent with the required quota of any agent shared resources. If more than one suitable agent has any available allocate of the resource, then the one with the highest number will be selected to execute the stage.