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
{{ message }}
This repository was archived by the owner on Sep 11, 2023. It is now read-only.
A status can be conditionally updated by using the `whenState` argument. This will first check that the current status is in one of the given states before it updates.
28
+
29
+
For the example below, it will only update the status if it is in one of the following states:
Copy file name to clipboardExpand all lines: tasks/pull-request-status/README.md
+40-8Lines changed: 40 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,21 @@
17
17
state: notSet
18
18
useDefined: false #If set, overrides the value from `System.PullRequest.PullRequestId`
19
19
pullRequestId: $(System.PullRequest.PullRequestId) #If no id is given, the value from `System.PullRequest.PullRequestId` is taken. If a value is given, this overrides the value from `System.PullRequest.PullRequestId`
20
+
whenState: #Only update the state of the status when the existing state is one of these
|`useDefined` <br />Use defined id |**(Optional)** If set, overrides the value from `System.PullRequest.PullRequestId` <br /> |
32
-
|`pullRequestId` <br />Pull Request Id |**(Optional)** If no id is given, the value from `System.PullRequest.PullRequestId` is taken. If a value is given, this overrides the value from `System.PullRequest.PullRequestId` <br /> Default value: `$(System.PullRequest.PullRequestId)`|
|`useDefined` <br />Use defined id |**(Optional)** If set, overrides the value from `System.PullRequest.PullRequestId` <br /> |
33
+
|`pullRequestId` <br />Pull Request Id |**(Optional)** If no id is given, the value from `System.PullRequest.PullRequestId` is taken. If a value is given, this overrides the value from `System.PullRequest.PullRequestId` <br /> Default value: `$(System.PullRequest.PullRequestId)`|
34
+
|`whenState` <br />When current status is in state |**(Optional)** Only update the state of the status when the existing state is one of these <br /> Options: `notSet`, `error`, `failed`, `notApplicable`, `pending`, `succeeded` <br /> |
33
35
34
36
35
37
## Examples
@@ -56,10 +58,40 @@ steps:
56
58
57
59
```
58
60
61
+
### Conditionally update status
62
+
63
+
A status can be conditionally updated by using the `whenState` argument. This will first check that the current status is in one of the given states before it updates.
64
+
65
+
For the example below, it will only update the status if it is in one of the following states:
66
+
67
+
- Error
68
+
- Failed
69
+
- Pending
70
+
71
+
```yml
72
+
- task: PullRequestStatus@0
73
+
displayName: 'Initialize status'
74
+
inputs:
75
+
name: 'my-custom-check'
76
+
action: 'Create'
77
+
state: 'pending'
78
+
description: 'Awaiting my custom check'
79
+
- script: 'echo Do something. It might even update the status'
80
+
- task: PullRequestStatus@0
81
+
displayName: 'Update status'
82
+
inputs:
83
+
name: 'my-custom-check'
84
+
action: 'Update'
85
+
state: 'succeeded'
86
+
description: 'Check passed'
87
+
whenState: 'error, failed, pending'
88
+
```
89
+
59
90
# 🐞 Known issues
60
91
61
92
If using classic pipelines and you get the error:
62
93
63
94
> TF400813: The user '' is not authorized to access this resource.
64
95
65
96
Ensure `Allow scripts to access the OAuth token` is checked under options. See the [docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/options?view=azure-devops#allow-scripts-to-access-the-oauth-token) for more info.
A status can be conditionally updated by using the `whenState` argument. This will first check that the current status is in one of the given states before it updates.
26
+
27
+
For the example below, it will only update the status if it is in one of the following states:
0 commit comments