Search code examples
azure-pipelinesazure-pipelines-build-task

Azure DevOps Pipeline lockbehavior in simple build pipeline (no deployment/release)


is it possible to use the lockBehavior (see https://learn.microsoft.com/en-us/azure/devops/release-notes/2021/sprint-190-update#support-for-sequential-deployments-rather-than-latest-only-when-using-exclusive-lock-checks) in a simple build pipeline?

I have a build or in my word "test pipeline" that has pipelines triggers on other build pipelines. This test pipeline use azure resources (vms) an can not run in parallel. Currently i create a simple custom script that use the azure devops pipelines rest api to lock the critical step who access the azure resources and all the other parallel pipeline runs must wait to get access.

I have create some test pipelines (no release pipeline! no deployment tasks) to check the "lockBehavior" but it has no effect and im not sure if its possible, because the docu of the feature says something von deloyments and stages.

Have any one else these kind of problem?

regards


Solution

  • According to the doc: https://learn.microsoft.com/en-us/azure/devops/release-notes/2021/sprint-190-update#support-for-sequential-deployments-rather-than-latest-only-when-using-exclusive-lock-checks

    To use exclusive lock check with sequential deployments or runLatest, follow these steps:

    1.Enable the exclusive lock check on the environment (or another protected resource).

    2.In the YAML file for the pipeline, specify a new property called lockBehavior. This can be specified for the whole pipeline or for a given stage.

    Checks are used to control the execution of stages on protected resources: https://learn.microsoft.com/en-us/azure/devops/pipelines/security/resources?view=azure-devops&preserve-view=true#protected-resources

    Enable this with the target protected resource first.

    Environments sample:

    enter image description here

    Variable groups:

    enter image description here