You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article discusses resources for YAML pipelines. A resource is anything a pipeline uses that exists outside that pipeline. Resources in YAML pipelines can be other pipelines, builds, containers, packages, repositories, or webhooks. After you define a resource, you can consume it anywhere in your pipeline. For more information and examples, see [Resource definitions](#resource-definitions).
14
+
This article discusses resources for YAML pipelines. A resource is anything a pipeline uses that exists outside that pipeline. Resources in YAML pipelines can be other pipelines, builds, containers, packages, repositories, or webhooks.
15
+
16
+
After you define a resource, you can consume it anywhere in your pipeline. For more information and examples, see [Resource definitions](#resource-definitions).
15
17
16
18
You can use resource status to automatically [trigger](#triggers) pipelines by setting the `trigger` property in the resource definition. When a resource triggers a pipeline run, the pipeline `resources.triggeringAlias` and `resources.triggeringCategory` variables are set to the resource name and category. These variables are empty unless the `Build.Reason` variable is set to `ResourceTrigger`.
17
19
18
20
Resources allow full [traceability](#traceability) for the services a pipeline uses, including version, artifacts, associated commits, and work items. If you subscribe to trigger events on your resources, you can fully automate your DevOps workflows.
Resources must be authorized to be used in YAML pipelines. Resource owners control the users and pipelines that can access their resources. There are several ways to authorize a YAML pipeline to use resources.
24
27
25
28
- You can use the resource's administration settings to authorize **all pipelines** to access the resource. For example, you can manage secure files and variable groups in the **Library** page under **Pipelines**, and agent pools and service connections in **Project settings**. This authorization is convenient for resources you don't need to restrict, such as test resources.
26
29
27
-
- Make sure you have at least **User** role in the [agent pool security roles](../../organizations/security/about-security-roles.md#agent-pool-security-roles-project-level) for your project. YAML pipelines you create are automatically authorized to use resources that you have **User** role for.
30
+
- Make sure you have at least **User** role in the [agent pool security roles](../../organizations/security/about-security-roles.md#agent-pool-security-roles-project-level) for your project. YAML pipelines you create are automatically authorized to use resources that you have **User** role on.
31
+
32
+
- If you add a resource definition to a YAML pipeline but the build fails with an error like `Could not find a <resource> with name <resource-name>. The <resource> does not exist or has not been authorized for use`, make sure you have at least **User** role on the resource. You can then choose the option to authorize the resources on the failed build. Once the resource is authorized, you can start a new build.
28
33
29
34
## Approval checks for resources
30
35
@@ -97,13 +102,13 @@ resources:
97
102
98
103
Azure Pipelines evaluates the default versions for resources based on their resource definitions. A pipeline's default resource artifact versions depend on whether the pipeline runs manually or on schedule, or triggers based on the outcome of the resource run.
99
104
100
-
For scheduled runs, or manual runs if you don't use the version picker, Azure Pipelines considers only successfully completed continuous integration (CI) runs when evaluating default resource versions. For manual runs, you can override the defined versions by using the [manual version picker](#manual-resource-version-picker).
101
-
102
105
For a manual or scheduled pipeline run, the values of the `version`, `branch`, and `tags` properties in the `pipeline` resource definition define the artifact versions. The `branch` input can't have wildcards, and the `tags` properties use the `AND` operator.
103
106
107
+
For scheduled runs, or manual runs if you don't use the version picker, Azure Pipelines considers only successfully completed continuous integration (CI) runs when evaluating default resource versions. For manual runs, you can override the defined versions by using the [manual version picker](#manual-resource-version-picker).
108
+
104
109
The following table lists `pipeline` resource definition properties and the artifact versions they specify.
105
110
106
-
|Specified properties | Artifact version |
111
+
|Specified property | Artifact version |
107
112
|---------|---------|
108
113
| `version` | Build that has the specified run number |
109
114
| `branch` | Latest build that ran on the specified branch |
@@ -130,7 +135,7 @@ resources:
130
135
<a name="triggers"></a>
131
136
#### Pipeline resource triggers
132
137
133
-
For pipeline runs that are triggered by the outcome of a resource run, the `trigger` property settings in the resource definition determine the default resource artifact versions. To use a `pipeline` resource as a trigger to run the current pipeline, set the `trigger` property in the `pipeline` resource definition. If you don't include a `trigger` property, resource runs don't trigger current pipeline runs.
138
+
For pipeline runs that trigger by the outcome of a resource run, the `trigger` property settings in the resource definition determine the default resource artifact versions. To use a `pipeline` resource as a trigger to run the current pipeline, set the `trigger` property in the `pipeline` resource definition. If you don't include a `trigger` property, resource runs don't trigger current pipeline runs.
134
139
135
140
When a pipeline triggers based on a `trigger` value in a `pipeline` resource definition, the values of the overall resource definition `version`, `branch`, and `tags` properties are ignored. The `trigger` properties determine the artifact versions.
136
141
@@ -293,7 +298,7 @@ If you have a CI build system that produces artifacts, you can consume the artif
293
298
294
299
The `builds` category is extensible. A `build` resource can be from any external CI system like Jenkins, TeamCity, or CircleCI. You can use `builds` to write an extension to consume artifacts from your build service or introduce a new type of service.
295
300
296
-
In the `build` definition, `version` defaults to the latest successful build. You must explicitly set `trigger` if desired. For complete schema information, see the [resources.builds.build](/azure/devops/pipelines/yaml-schema/resources-builds-build) definition.
301
+
In the `build` definition, `version` defaults to the latest successful build. You must explicitly set `trigger` if desired. For complete schema information, see the [resources.builds.build](/azure/devops/pipelines/yaml-schema/resources-builds-build) definition.
297
302
298
303
In the following example, Jenkins is the resource type.
299
304
@@ -330,7 +335,7 @@ The optional `patterns` property defines a minimatch path or list of [minimatch
330
335
For complete schema information, see the [steps.downloadBuild](/azure/devops/pipelines/yaml-schema/steps-download-build) definition.
331
336
332
337
<a name="define-a-repositories-resource"></a>
333
-
### Repository resource
338
+
### Repositories resource
334
339
335
340
Use the `repository` keyword to let the system know about external repositories if:
336
341
@@ -362,7 +367,7 @@ The following table describes the `repository` resource types:
362
367
363
368
|Type |Name value |Example |
364
369
|---------|---------|---------|
365
-
|`git` | A different repository in the same project or same organization. | Same project: `name: otherRepo`<br>Another project in the same organization:`name: otherProject/otherRepo`. |
370
+
|`git` | A different repository in the same project or same organization. | Same project: `name: otherRepo`<br>Another project in the same organization:<br>`name: otherProject/otherRepo`. |
366
371
|`github` | Full name of the GitHub repository including the user or organization. | `name: myOrganization/otherRepo` |
367
372
|`githubenterprise` | Full name of the GitHub Enterprise repository including the user or organization. | `name: myEnterpriseOrg/otherRepo` |
368
373
|`bitbucket` | Full name of the Bitbucket Cloud repository including the user or organization. | `name: MyBitbucketOrg/otherRepo` |
The following example has an alias of `common`, , so you access the repository resource variables using `resources.repositories.common.*`.
429
+
The following example has an alias of `common`, so you access the repository resource variables using `resources.repositories.common.*`.
425
430
426
431
```yaml
427
432
resources:
@@ -573,9 +578,11 @@ steps:
573
578
574
579
You can consume artifacts and enable automated triggers with pipeline, container, build, and package resources. However, you can't use these resources to automate your deployments based on external events or services.
575
580
576
-
The `webhooks` resource in YAML pipelines lets you integrate your pipelines with external services like GitHub, GitHub Enterprise, Nexus, and Artifactory to automate workflows. You can subscribe to external events through webhooks and use the events to trigger your pipelines.
581
+
Webhooks automate your workflow based on external webhook events that first-class pipeline, build, container, or package resources don't support. You can subscribe to external events through webhooks and use the events to trigger your pipelines.
577
582
578
-
To subscribe to a webhook event, you define a webhook resource in your pipeline and point it to an incoming webhook service connection. The following example defines and calls a webhook resource:
583
+
The `webhooks` resource in YAML pipelines lets you integrate your pipelines with external services like GitHub, GitHub Enterprise, Nexus, and Artifactory to automate workflows. For on-premises services where Azure DevOps doesn't have visibility into the process, you can configure webhooks on the service to trigger your pipelines automatically.
584
+
585
+
To subscribe to a webhook event, you define a `webhook` resource in your pipeline and point it to an incoming webhook service connection. The following example defines and calls a webhook resource:
579
586
580
587
```yaml
581
588
resources:
@@ -589,8 +596,6 @@ steps:
589
596
590
597
For complete schema information, see the [resources.webhooks.webhook](/azure/devops/pipelines/yaml-schema/resources-webhooks-webhook) definition.
591
598
592
-
Webhooks automate your workflow based on external webhook events that aren't supported by first-class pipelines, builds, containers, or packages resources. For on-premises services where Azure DevOps doesn't have visibility into the process, you can configure webhooks on the service to trigger your pipelines automatically.
593
-
594
599
You can consume the JSON payload data in your jobs as variables by using the format `${{ parameters.<WebhookAlias>.<JSONPath>}}`. You can define filters on the webhook resource based on the JSON payload data to customize triggers for each pipeline. Whenever the incoming webhook service connection receives a webhook event, a new run triggers for all the pipelines subscribed to the webhook event.
595
600
596
601
#### Webhook trigger configuration
@@ -675,7 +680,7 @@ After a pipeline deploys to an environment, you can see a list of resources that
675
680
676
681
Using a `pipelines` resource is a way to consume artifacts from a CI pipeline and also configure automated triggers. A resource gives you full visibility into the process by displaying the version consumed, artifacts, commits, and work items. When you define a pipeline resource, the associated artifacts are automatically downloaded in deployment jobs.
677
682
678
-
You can use the `download` shortcut to download the artifacts in build jobs or to override the download behavior in deployment jobs. For more information, see the [steps.download] definition(/azure/devops/pipelines/yaml-schema/steps-download).
683
+
You can use the `download` shortcut to download the artifacts in build jobs or to override the download behavior in deployment jobs. For more information, see the [steps.download](/azure/devops/pipelines/yaml-schema/steps-download) definition.
679
684
680
685
The [Download Pipeline Artifacts task](/azure/devops/pipelines/tasks/reference/download-pipeline-artifact-v2) doesn't provide traceability or triggers, but sometimes it makes sense to use this task directly. For example, you might have a script task stored in a different template that requires artifacts from a build to be downloaded. Or, you might not want to add a pipeline resource to a template. To avoid dependencies, you can use the Download Pipeline Artifacts task to pass all the build information to a task.
681
686
@@ -717,12 +722,6 @@ If you receive a 500 status code response with the error `Cannot find webhook fo
717
722
1. After this pipeline runs successfully, perform a `POST` API call with valid JSON in the body to
718
723
`https://dev.azure.com/<organization>/_apis/public/distributedtask/webhooks/<webhook-name>?api-version=<apiversion>`. You should now receive a 200 status code response.
719
724
720
-
### Why did my build fail with a not-authorized message?
721
-
722
-
If you add a resource definition to a YAML pipeline but the build fails with an error like `Could not find a <resource> with name <resource-name>. The <resource> does not exist or has not been authorized for use.`, verify that the [agent pool security roles](../../organizations/security/about-security-roles.md) for your project are correct.
723
-
724
-
If you have **User** role on the resource, you can choose the option to authorize the resources on the failed build. Once the resource is authorized, you can start a new build.
0 commit comments