Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression-based job filters #9046

Merged
merged 10 commits into from
Nov 13, 2024
Merged

Conversation

rosieyohannan
Copy link
Contributor

@rosieyohannan rosieyohannan commented Oct 30, 2024

Description

  • Add section to config reference for expression filters
  • Add examples
  • Reuse operators from context restrictions page - make partial and include in both files

Reasons

Expression-based job filters now available

Content Checklist

Please follow our style when contributing to CircleCI docs. Our style guide is here: https://circleci.com/docs/style/style-guide-overview.

Please take a moment to check through the following items when submitting your PR (this is just a guide so will not be relevant for all PRs) 😸:

  • Break up walls of text by adding paragraph breaks.
  • Consider if the content could benefit from more structure, such as lists or tables, to make it easier to consume.
  • Keep the title between 20 and 70 characters.
  • Consider whether the content would benefit from more subsections (h2-h6 headings) to make it easier to consume.
  • Check all headings h1-h6 are in sentence case (only first letter is capitalized).
  • Is there a "Next steps" section at the end of the page giving the reader a clear path to what to read next?
  • Include relevant backlinks to other CircleCI docs/pages.

@rosieyohannan rosieyohannan changed the title [WIP] Expression-based job filters Expression-based job filters Nov 6, 2024
@rosieyohannan rosieyohannan marked this pull request as ready for review November 6, 2024 13:17
@rosieyohannan rosieyohannan requested review from a team as code owners November 6, 2024 13:17

**Examples**

Allow the job to run only on the project's `main` branch:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~ What do you think about

Only run the job on the project's main branch:

I feel we should avoid using words like "allow" or "deny" because they imply a permission control but since anybody can modify the filters for commits the push on an unprotected branch they can always make the job run if they want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah agreed. This language is there due to being copied over from context restrictions 🙈

@@ -1761,7 +1761,7 @@ While this improves performance in most cases, if a downstream step requires tho
----
====

A special step used to check out source code to the configured `path` (defaults to the `working_directory`). The reason this is a special step is because it is more of a helper function designed to make checking out code easy for you. If you require doing git over HTTPS you should not use this step as it configures git to checkout over SSH.
A special step used to check out source code to the configured `path` (defaults to the `working_directory`). The reason this is a special step is because it is more of a helper function designed simplify the process of checking out code. If you require doing git over HTTPS you should not use this step as it configures git to checkout over SSH.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~ missing "to", i.e. designed to simplify?

@@ -2713,10 +2718,10 @@ NOTE: Workflows will ignore job-level branching. If you use job-level branching
| `filters`
| N
| Map
| A map defining rules for execution on specific branches
| A map defining rules for execution on specific branches, tags, or based on an expression-based condition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filters is now either a map, or a string. If it's a string then it's an expression filter, otherwise it's the older branches/tags structure.

----

The above snippet causes the job `build_server_pdfs` to only be run when the branch being built starts with "server/".
Only run the job on the `main` branch, and disallow use with pipelines xref:vs-code-extension-overview#test-run-your-config-from-vs-code[triggered with unversioned configuration]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about

Only run the job on the main branch, but not if the pipeline was triggered with unversioned configuration

?

@rosieyohannan rosieyohannan merged commit 26ff119 into master Nov 13, 2024
3 checks passed
@rosieyohannan rosieyohannan deleted the DOCSS-1637-expression-job-filters branch November 20, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants