Skip to content

Commit c7ecf7d

Browse files
ericscipleam-stead
andauthored
Document expression evaluation logs for job conditions (#59100)
Co-authored-by: Anne-Marie <102995847+am-stead@users.noreply.github.com>
1 parent dd56557 commit c7ecf7d

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

content/actions/how-tos/monitor-workflows/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ children:
1111
- /view-job-execution-time
1212
- /add-a-status-badge
1313
- /use-workflow-run-logs
14+
- /view-job-condition-logs
1415
- /enable-debug-logging
1516
redirect_from:
1617
- /actions/monitoring-and-troubleshooting-workflows/monitoring-workflows
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Viewing job condition expression logs
3+
shortTitle: View job condition logs
4+
intro: 'Learn how to access and interpret expression evaluation logs for job-level `if` conditions in {% data variables.product.prodname_actions %}.'
5+
versions:
6+
fpt: '*'
7+
ghec: '*'
8+
contentType: how-tos
9+
---
10+
11+
When a job's `if` condition is evaluated, {% data variables.product.prodname_actions %} logs the expression evaluation to help you understand the result. This is useful for debugging both why a job was skipped and why a job ran when you expected it to be skipped.
12+
13+
## Accessing expression logs
14+
15+
1. Navigate to the workflow run summary.
16+
1. Click on the job.
17+
1. Click **{% octicon "gear" aria-label="The Gear icon" %}**.
18+
1. Select **Download log archive**.
19+
1. Extract the ZIP file and open the `JOB-NAME/system.txt` file.
20+
21+
## Understanding the log output
22+
23+
The system log shows the expression evaluation:
24+
25+
```text
26+
Evaluating: (success() && ((github.repository == 'octo-org/octo-repo-prod')))
27+
Expanded: (true && (('my-username/octo-repo-prod' == 'octo-org/octo-repo-prod')))
28+
Result: false
29+
```
30+
31+
| Line | Description |
32+
|------|-------------|
33+
| **Evaluating** | The original `if` expression from your workflow file. |
34+
| **Expanded** | The expression with context values substituted. This shows you exactly what values were used at runtime. |
35+
| **Result** | The final evaluation result (`true` or `false`). |
36+
37+
In this example, the expanded line reveals that `github.repository` was `'my-username/octo-repo-prod'` (not `'octo-org/octo-repo-prod'`), which caused the condition to evaluate to `false`.
38+
39+
> [!NOTE]
40+
> Expression logs are only available for job-level `if` conditions. For step-level conditions, you can enable debug logging to see expression evaluation in the job logs. For more information, see [AUTOTITLE](/actions/how-tos/monitor-workflows/enable-debug-logging).

content/actions/how-tos/troubleshoot-workflows.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ For path filtering, evaluating diffs is limited to the first 300 files. If there
9898

9999
Workflow execution involves any issues seen after the workflow was triggered and a workflow run has been created.
100100

101+
{% ifversion fpt or ghec %}
102+
103+
### Debugging job conditions
104+
105+
If a job was skipped unexpectedly, or ran when you expected it to be skipped, you can view the expression evaluation to understand why:
106+
107+
1. Click on the job in the workflow run.
108+
1. Download the log archive from the job's menu.
109+
1. Open the `JOB-NAME/system.txt` file.
110+
1. Look for the `Evaluating`, `Expanded`, and `Result` lines.
111+
112+
The `Expanded` line shows the actual runtime values that were substituted into your `if` condition, making it clear why the expression evaluated to `true` or `false`.
113+
114+
For more information, see [AUTOTITLE](/actions/how-tos/monitor-workflows/view-job-condition-logs).
115+
116+
{% endif %}
117+
101118
### Canceling Workflows
102119

103120
If standard cancellation through the [UI](/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/canceling-a-workflow) or [API](/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run) does not process as expected, there may be a conditional statement configured for your running workflow job(s) that causes it to not cancel.

content/actions/how-tos/write-workflows/choose-when-workflows-run/control-jobs-with-conditions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ Skipped jobs display the message "This check was skipped."
3737
3838
> [!NOTE]
3939
> A job that is skipped will report its status as "Success". It will not prevent a pull request from merging, even if it is a required check.
40+
41+
{% ifversion fpt or ghec %}
42+
43+
To debug why a job was skipped or ran unexpectedly, you can view job condition expression logs. For more information, see [AUTOTITLE](/actions/how-tos/monitor-workflows/view-job-condition-logs).
44+
45+
{% endif %}

0 commit comments

Comments
 (0)