Skip to content

Commit 72141f8

Browse files
committed
some edits
1 parent 9345c91 commit 72141f8

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

docs/pipelines/process/resources.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ monikerRange: "<=azure-devops"
1111

1212
[!INCLUDE [version-gt-eq-2019](../../includes/version-gt-eq-2019.md)]
1313

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. 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).
1517

1618
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`.
1719

1820
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.
1921

22+
<a name="resource-authorization-in-yaml-pipelines"></a>
2023
<a name="authorize-a-yaml-pipeline"></a>
2124
## Resource authorization
2225

2326
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.
2427

2528
- 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.
2629

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.
2833

2934
## Approval checks for resources
3035

@@ -97,13 +102,13 @@ resources:
97102

98103
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.
99104

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-
102105
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.
103106

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+
104109
The following table lists `pipeline` resource definition properties and the artifact versions they specify.
105110

106-
|Specified properties | Artifact version |
111+
|Specified property | Artifact version |
107112
|---------|---------|
108113
| `version` | Build that has the specified run number |
109114
| `branch` | Latest build that ran on the specified branch |
@@ -130,7 +135,7 @@ resources:
130135
<a name="triggers"></a>
131136
#### Pipeline resource triggers
132137

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.
134139

135140
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.
136141

@@ -293,7 +298,7 @@ If you have a CI build system that produces artifacts, you can consume the artif
293298

294299
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.
295300

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.
297302

298303
In the following example, Jenkins is the resource type.
299304

@@ -330,7 +335,7 @@ The optional `patterns` property defines a minimatch path or list of [minimatch
330335
For complete schema information, see the [steps.downloadBuild](/azure/devops/pipelines/yaml-schema/steps-download-build) definition.
331336

332337
<a name="define-a-repositories-resource"></a>
333-
### Repository resource
338+
### Repositories resource
334339

335340
Use the `repository` keyword to let the system know about external repositories if:
336341

@@ -362,7 +367,7 @@ The following table describes the `repository` resource types:
362367

363368
|Type |Name value |Example |
364369
|---------|---------|---------|
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`. |
366371
|`github` | Full name of the GitHub repository including the user or organization. | `name: myOrganization/otherRepo` |
367372
|`githubenterprise` | Full name of the GitHub Enterprise repository including the user or organization. | `name: myEnterpriseOrg/otherRepo` |
368373
|`bitbucket` | Full name of the Bitbucket Cloud repository including the user or organization. | `name: MyBitbucketOrg/otherRepo` |
@@ -421,7 +426,7 @@ resources.repositories.<alias>.url
421426
resources.repositories.<alias>.version
422427
```
423428

424-
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.*`.
425430

426431
```yaml
427432
resources:
@@ -573,9 +578,11 @@ steps:
573578

574579
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.
575580

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.
577582

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:
579586

580587
```yaml
581588
resources:
@@ -589,8 +596,6 @@ steps:
589596

590597
For complete schema information, see the [resources.webhooks.webhook](/azure/devops/pipelines/yaml-schema/resources-webhooks-webhook) definition.
591598

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-
594599
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.
595600

596601
#### Webhook trigger configuration
@@ -675,7 +680,7 @@ After a pipeline deploys to an environment, you can see a list of resources that
675680

676681
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.
677682

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.
679684

680685
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.
681686

@@ -717,12 +722,6 @@ If you receive a 500 status code response with the error `Cannot find webhook fo
717722
1. After this pipeline runs successfully, perform a `POST` API call with valid JSON in the body to
718723
`https://dev.azure.com/<organization>/_apis/public/distributedtask/webhooks/<webhook-name>?api-version=<apiversion>`. You should now receive a 200 status code response.
719724

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.
725-
726725
### Why didn't my resource trigger work?
727726

728727
Resource triggers can fail to execute because:

0 commit comments

Comments
 (0)