I have two pipelines, the first one is triggering the second one which deploys application. The first one works, however can't trigger the second one (earlier it works until the first one was moved to different organization), so I start read the Microsoft documentation If I miss something in my pipeline code when we have two different organizations for those two pipelines?
When I run manually the second one, it throws the error:
(Line: 24, Col: 7): Pipeline Resource Coin Input Must be Valid.
Extracted code snippet for second pipeline:
resources:
repositories:
- repository: Stock-coin
type: git
name: Stock-coin/Stock-coin
ref: main
endpoint: Stock-coin-connection
- repository: CICD
type: git
name: AzureDevOps/Templates
ref: main
pipelines:
- pipeline: Coin
source: 'Coin'
project: Stock-coin
trigger: true
Meanwhile I added new service connection, and each time when I am changing the - pipeline
scope I am getting the same error. The first pipeline is in the Stock-coin
project, the pipeline is called Coin
, so such data I put in above pipelines
section.
The Pipelines resource can only available for the pipelines within the same Azure DevOps organization. It is not available for different organization.
As a workaround, you can consider using the Webhooks resource with Webhook triggers to trigger the pipeline from another organization.
Suppose there are 2 pipelines:
If you want to use Pipeline1 to trigger Pipeline2, you can configure like as below:
In the project where Pipeline2 is in, go to "Project Settings" > "Service connections" to create an Incoming WebHook service connection.
In the project where Pipeline1 is in, go to "Project Settings" > "Service Hooks" to create a subscription of Web Hooks.
Trigger on this type of event
" is "Build completed
", "Build pipeline
" is the actual definition name of Pipeline1, "Build Status
" is "Succeeded
".URL
" is the below. The <organization-name>
is the actual name of the Organization2 where Pipeline2 is in. The <webhook-name>
should be the same as the WebHook Name set on above Incoming WebHook service connection.
https://dev.azure.com/<organization-name>/_apis/public/distributedtask/webhooks/<webhook-name>?api-version=6.0-preview
Then you can configure a Webhook trigger in Pipeline2 like as below.
resources:
webhooks:
- webhook: PipelineCompleted # The WebHook Name set on the Incoming WebHook service connection.
connection: PipelineFromDiffOrg # The name of Incoming WebHook service connection.
filters:
- path: resource.definition.name
value: 'MathCalc' # The actual definition name of Pipeline1.
variables:
resPipe.definitionName: ${{ parameters.PipelineCompleted.resource.definition.name }}
resPipe.definitionId: ${{ parameters.PipelineCompleted.resource.definition.id }}
resPipe.buildNumber: ${{ parameters.PipelineCompleted.resource.buildNumber }}
resPipe.buildId: ${{ parameters.PipelineCompleted.resource.id }}
steps:
- script: |
echo "resPipe.definitionName = $(resPipe.definitionName)"
echo "resPipe.definitionId = $(resPipe.definitionId)"
echo "resPipe.buildNumber = $(resPipe.buildNumber)"
echo "resPipe.buildId = $(resPipe.buildId)"
With above configuration, when a build/run of Pipeline1 in Organization1 is completed successfully, a build/run of Pipeline2 in Organization2 will be automatically triggered.