Search code examples
azure-devopsazure-pipelinesazure-pipelines-release-pipeline

how to verify if other build has been built successfully before deploying the release in azure devops


We have a requirement where after the QA2 Release we have to trigger a build which will do some activity in qa2 and create a build. We have to pass some parameters or change some if build fails so we cannot keep it in the normal release pipeline. We wanted to know if there is any way to keep check so that if the build passes then only it will be allowed to be deployed to prod otherwise shouldnt allow. Current structure

Is there any gates or checks available to make this possible?


Solution

  • Sure, you can use the Gates on the "Pre-deployment conditions" of PROD stage. you just need to use the Invoke REST API check to call the REST API "Latest - Get".

    1. Go to "Project Settings" > "Service connections" to create a Generic service connection. The values of the following two field are required.

      • Server URL: The prefix of the HTTP URL of the API. For example, https://dev.azure.com/{orgName}. The {orgName} is the actual name of your Azure DevOps organization.
      • Service connection name: A custom name of the service connection.

      enter image description here

    2. On the "Pre-deployment conditions" of PROD stage, enable Gates and add the Invoke REST API check with below configurations.

      • Connection type: Generic

      • Generic service connection: Name of the Generic service connection create previously.

      • Method: GET

      • Headers (json):

        {
          "Content-Type":"application/json", 
          "Authorization": "Bearer $(system.AccessToken)"
        }
        
      • URL suffix and parameters: /{projName}/_apis/build/latest/{definitionId}?api-version=7.0-preview.1

        The {projName} is the actual name of your project, and the {definitionId} is the definition ID of the build pipeline (QA2 Test Build).

      • Advanced > Completion event: ApiResponse

      • Advanced > Success criteria: eq(root['result'], 'succeeded')

      enter image description here