Skip to content

Commit bcc95e1

Browse files
authored
doc: Added Special CEL Expr in Filter Condition doc (#5850)
* Added Special Regex in Filter Condition doc * Added fixed branch expression * Replaced Video + Occurences of Regex
1 parent 75fa635 commit bcc95e1

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

docs/user-guide/global-configurations/filter-condition.md

+28-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Using filter conditions, you can control the progression of events. Here are a f
88
* Images containing the label "test" should not be eligible for deployment in production environment
99
* Only images having tag versions greater than v0.7.4 should be eligible for deployment
1010
* Images hosted on Docker Hub should be eligible but not the rest
11+
* Only images derived from master branch should be eligible for production deployment (see [example](#scenario-2))
1112

1213
---
1314

@@ -55,17 +56,17 @@ You must have application(s) with CI-CD workflow(s) configured
5556

5657
![Figure 5: Selecting Environment(s) from Cluster(s)](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/global-configurations/filters/environment-selection.jpg)
5758

58-
{% hint style="info" %}
59-
Since an application can have more than one environment, the filter conditions apply only to the environment you chose in the **Apply to** section. If you create a filter condition without choosing an application or environment, it will not apply to any of your pipelines.
60-
{% endhint %}
59+
{% hint style="info" %}
60+
Since an application can have more than one environment, the filter conditions apply only to the environment you chose in the **Apply to** section. If you create a filter condition without choosing an application or environment, it will not apply to any of your pipelines.
61+
{% endhint %}
6162

6263
6. Click **Save**. You have successfully created a filter.
6364

6465
![Figure 6: Success Toast](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/global-configurations/filters/filter-created.jpg)
6566

66-
{% hint style="warning" %}
67-
If you create filters using CEL expressions that result in a conflict (i.e., passing and failing of the same image), fail will have higher precedence
68-
{% endhint %}
67+
{% hint style="warning" %}
68+
If you create filters using CEL expressions that result in a conflict (i.e., passing and failing of the same image), fail will have higher precedence
69+
{% endhint %}
6970

7071
---
7172

@@ -78,6 +79,8 @@ Here's a sample pipeline we will be using for our explanation of [pass condition
7879

7980
### Pass Condition
8081

82+
#### Scenario 1
83+
8184
Consider a scenario where you wish to make an image eligible for deployment only if its tag version is greater than `v0.0.7`
8285

8386
The CEL Expression should be `containerImageTag > "v0.0.7"`
@@ -102,6 +105,25 @@ Clicking the filter icon at the top-left shows the filter condition(s) applied t
102105

103106
![Figure 12b: Conditions Applied](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/global-configurations/filters/conditions-applied-1.jpg)
104107

108+
#### Scenario 2
109+
110+
Consider another scenario where you wish to make images eligible for deployment only if the application's git branch starts with the word `hotfix` and also if its repo URL matches your specified condition.
111+
112+
**CEL Expression**:
113+
114+
`gitCommitDetails.filter(gitCommitDetail, gitCommitDetail.startsWith('https://github.com/devtron-labs')).map(repo, gitCommitDetails[repo].branch).exists_one(branch, branch.startsWith('hotfix-'))`
115+
116+
where, `https://github.com/devtron-labs` is a portion of the repo URL <br />
117+
and `hotfix-` is for finding the branch name (say *hotfix-sept-2024*)
118+
119+
Alternatively, if you have a fixed branch (say *hotfix-123*), you may write the following expression:
120+
121+
`'hotfix-123' in gitCommitDetails.filter(gitCommitDetail, gitCommitDetail.startsWith('https://github.com/devtron-labs')).map(repo, gitCommitDetails[repo].branch)`
122+
123+
**Walkthrough Video**:
124+
125+
{% embed url="https://www.youtube.com/watch?v=R8IbZhXhH-k" caption="Filter Condition Example" %}
126+
105127

106128
### Fail Condition
107129

0 commit comments

Comments
 (0)