Search code examples
amazon-ec2azure-devopsazure-pipelines-release-pipelineazure-devops-self-hosted-agent

Azure DevOps Multiple Release Pipelines


Is it possible to create a master release pipeline that will trigger sub pipelines in Azure DevOps?

We are working on Deploying some packages to EC2 Server using vsts Agent and call batch scripts. Currently we are creating pipeline for each package. But these packages keep changing in every release and we want to add flexibility in a master pipeline where we could choose sub pipelines to be triggered. Any idea on how to achieve this?


Solution

  • we want to add flexibility in a master pipeline where we could choose sub pipelines to be triggered

    For this issue, there is a custom task in the Azure DevOps marketplace: Trigger Azure DevOps pipeline. With this task you can trigger a build or release pipeline from another pipeline within the same project or organization but also in another project or organization.

    enter image description here

    You can also add a powershell task to call the rest api to queue another release pipeline.

    $token = "{PAT}"   
    $url = "https://vsrm.dev.azure.com/{Org name}/{Project name}/_apis/Release/releases?api-version=5.0"
    $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
    
    
    $JSON = @"
    {
      "definitionId": {release-def-2 definition ID}
    }
    "@
    
    $response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
    
    }