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

using "when condition" at workflow level causes unhelpful error: Error: All Workflows have been filtered from this Pipeline. #577

Open
airtonix opened this issue Feb 22, 2021 · 26 comments
Labels
bug Something isn't working

Comments

@airtonix
Copy link

airtonix commented Feb 22, 2021

Meta:

CircleCI CLI Version:

0.1.14915+4e9d967 (release)

Operating System:

 npx envinfo

  System:
    OS: macOS 11.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.30 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v12.13.1/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/zeno.jiricek/.rvm/gems/ruby-2.4.10/bin/pod
    Gradle: 6.8.1 - /usr/local/bin/gradle
    Homebrew: 3.0.1 - /usr/local/bin/brew
    Maven: 3.6.3 - /usr/local/bin/mvn
    pip3: 21.0.1 - /usr/local/bin/pip3
    RubyGems: 3.0.9 - /Users/zeno.jiricek/.rvm/rubies/ruby-2.4.10/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.24.3 - /usr/bin/git
    Clang: 1200.0.32.29 - /usr/bin/clang
  Servers:
    Apache: 2.4.46 - /usr/sbin/apachectl
  Virtualization:
    Docker: 20.10.2 - /usr/local/bin/docker
    VirtualBox: 5.2.12 - /usr/local/bin/vboxmanage
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Nano: 2.0.6 - /usr/bin/nano
    VSCode: 1.52.1 - /usr/local/bin/code
    Vim: 8.2 - /usr/bin/vim
    WebStorm: 2017.3.4
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Java: 1.8.0_222 - /usr/bin/javac
    Perl: 5.28.2 - /usr/bin/perl
    PHP: 7.3.24 - /usr/bin/php
    Python: 2.7.16 - /usr/bin/python
    Python3: 3.8.2 - /usr/bin/python3
    Ruby: 2.4.10 - /Users/zeno.jiricek/.rvm/rubies/ruby-2.4.10/bin/ruby
  Databases:
    SQLite: 3.32.3 - /usr/bin/sqlite3
  Browsers:
    Safari: 14.0.2
  Monorepos:
    Yarn Workspaces: 1.22.10

CircleCI CLI Diagnostic:

$ circleci diagnostic

---
CircleCI CLI Diagnostics
---
Debugger mode: false
Config found: /Users/zeno.jiricek/.circleci/cli.yml
API host: https://circleci.com
API endpoint: graphql-unstable
OK, got a token.
Trying an introspection query on API... 
Ok.
Hello, Zeno Jiricek.

Current behavior:

$ cat .circleci/config.yml
version: 2.1

jobs:
  foo:
    docker:
      - image: circleci/node:10
    steps:
      - checkout

workflows:
  version: 2

  master:

    when:
      or:
        - equal: [ master, << pipeline.git.branch >> ]

    jobs:
      - foo
$ circleci config validate
Error: All Workflows have been filtered from this Pipeline.
No Jobs have been run.

Expected behavior:

$ circleci config validate
Config file at .circleci/config.yml is valid.

When did this begin / Was this previously working?:

no idea

Additional Information:

nope.

@airtonix airtonix added the bug Something isn't working label Feb 22, 2021
@airtonix airtonix changed the title using when at worflow level causes unhelpful error: Error: All Workflows have been filtered from this Pipeline. using "when condition" at workflow level causes unhelpful error: Error: All Workflows have been filtered from this Pipeline. Feb 22, 2021
@alejandrod-f
Copy link

alejandrod-f commented Aug 27, 2021

Sounds to me that the error is on the server side. right?
I mean, if there is nothing to run. Why would it fail? Doesn't make sense

@mickutz
Copy link

mickutz commented Oct 27, 2021

This should really be fixed, as in under certain scenarios this is not actually an issue. I've added a pre-commit hook that triggers a validate against my config and need to disable it now as there's no workflow to run against my conditions.
I'd rather not add another pointless workflow as a workaround.

when:
      not:
        or:
          - equal: [ someValue, << pipeline.parameters.someParameter >> ]
          - equal: [ someOtherValue, << pipeline.parameters.someOtherParameter>> ]

@thopiddock
Copy link

This actively affects our pipeline as well where we're using the environment as a parameter and matching against the branch name to when: or: at the workflow level - I really do not want to have to add a superfluous workflow just to stop an overzealous error message.

@otherguy
Copy link

Same here. Using the new(ish) setup workflows and path filtering, sometimes there are no workflows to run. Right now I have a useless noop workflow but I would love to get rid of it.

@mathaeus
Copy link

mathaeus commented May 2, 2022

Any update on this one? Due to migrating from the deprecated "scheduled workflows" to "scheduled pipelines" we are also seeing this in some repos.

@viktorbahr
Copy link

viktorbahr commented May 4, 2022

Would also be interested in having this changed. We are using conditional workflows in combination with the path filtering orb to skip build steps if only certain files were changed. The current behavior is falsely indicating a failure of the CI pipeline.

@nicrom8b
Copy link

Hi folks, I had same problem. But I detected that it fixed up if remove version: 2 from workflow section.

@ruben1
Copy link
Contributor

ruben1 commented Jun 3, 2022

Hi, you're likely seeing this issue because you're running circleci config validate from a certain local branch and that gets prefilled into the pipeline values. Config compilation then works as usual.

I'm not sure I understand well your use case but we have a ticket in the backlog to let users pass their own pipeline values. That would enable you to do config validation based on pipeline values of your choice so you can create a realistic validation. For e.g. in your case pipeline.git.branch = master. Let us know if that would still not solve your use case though

@mathaeus
Copy link

mathaeus commented Jun 6, 2022

Hi @ruben1, the issue is not about circleci config validate spitting out an error. The OP just showcased the problem by using that command.

The underlying problem is that the when condition makes the whole CI workflow fail, if there is no workflow that matches any condition.
That is the problem where we'd love to see a fix for, because currently some of us have a dummy workflow set up, just so that this dummy workflow matches in case no other workflow matches, in order to prevent this failure on CI.

@ruben1
Copy link
Contributor

ruben1 commented Jun 14, 2022

@mathaeus thanks for the clarification, I routed this to the right internal team to look into it.

@JonTheStone
Copy link

Bumping this. It shouldn't be considered an error if all pipelines have been filtered.

@vmrvictor
Copy link

vmrvictor commented Jul 25, 2022

yeah we have also the same error, in the mean time, do you have any dummy noop implementation, any really light executor? I am using the executor that was already in the job but I would like to know if do you know a really light executor just to "do nothing"

in my case it looks like that

jobs:
  noop:
    executor: my-executor-which-needs-my-context
    steps:
      - run:
        command: |
          echo "do nothing"
          
....

workflows:
  noop:
    jobs:
      - noop:
          context: myContext

@mathaeus
Copy link

mathaeus commented Aug 1, 2022

@ruben1 any update on this? Thank you! :)

@dnhyde
Copy link

dnhyde commented Oct 14, 2022

I had the same issue, you should check your regex removing the version will just hide the warning and it is not a solution.

As per the official docs:

matches uses Java regular expressions
for its pattern. A full match pattern must be provided, prefix matching is not an option. Though, it is recommended to enclose a pattern in ^ and $ to avoid accidental partial matches.

Solution -> enclose your pattern in ^ and $ and check if it matches what you expect e.g. on regex101.

Tip: use single quotes in YAML if you get the following error:

Error: Unable to parse YAML while scanning a double-quoted scalar

@JonTheStone
Copy link

I could be misremembering as it has been a while but I believe the issue here is not a pipeline not being picked up, but that CircleCI considers any workflow that does not correlate with a pipeline to be an error and unintentional when some of us are intentionally filtering all pipelines and do not expect it to be an error.

@ruben1
Copy link
Contributor

ruben1 commented Nov 1, 2022

Hey folks, I escalated this to the internal team that owns that. It hasn't been prioritized as of now.

If you have an issue directly related with the CLI, feel free to update here/open issues in the repo but if your issue has to do with running pipelines in the core platform, I'd advise to go through the standard support channels so that there's more visibility into that and a faster solution.

@mathaeus
Copy link

mathaeus commented Nov 1, 2022

@ruben1 thanks for the update, what do you consider as "standard support channels"?

@adi-accessibe
Copy link

+1

@slayer321
Copy link

Hey, If you are facing this error and you use circleci config validate command as the pre-commit .. you can use below pre-commit repo. Here we just skip the know errors.
https://github.com/fluxninja/pre-commit-hooks

@Kylmakalle
Copy link

If you want to save a portion of credits for noop workflow, you can create a scheduled workflow that will never execute. e.g. February 31st

jobs:
  noop:
    docker:
      - image: cimg/base:current
    resource_class: small
    steps:
      - run: echo "noop"

workflows:
  noop: # This workflow is required, but will never run. https://github.com/CircleCI-Public/circleci-cli/issues/577
    triggers:
      - schedule:
          cron: "0 0 31 2 0" # February 31st
          filters:
            branches:
              only:
                - some_branch_that_will_never_exist_and_nobody_will_create_it
    jobs:
      - noop

@mathaeus
Copy link

I thought cron is not supported anymore 🤔

@Kylmakalle
Copy link

@mathaeus

Not yet.

Update 6-Dec-2022: We previously announced that we will be sunsetting scheduled workflows at the end of this year. Since that announcement went live, we’ve been closely tracking your feedback and feature requests, and have decided to postpone the deprecation - no new timelines are set yet.

https://discuss.circleci.com/t/scheduled-pipelines-are-here/41684/17

@mathaeus
Copy link

Thanks @Kylmakalle, I missed that update. Good to know 👍

@davidyuloom
Copy link

is there a resolution to this? still experiencing this issue in June 2023

@JonTheStone
Copy link

Same. My working example is that I want to run workflows when commits are pushed to my default branch, but all other branches are triggered manually via api. The noise from no workflow "errors" becomes almost unbearable.

@nawazishali
Copy link

nawazishali commented Apr 24, 2024

I had the same error and the following config worked for me. I hope this helps everyone else here. The problem only happened for me because of a mismatched regex. Basically you need at least one matching workflow to make it work.

version: 2.1

jobs:
  build:
    docker:
      - image: cimg/node:12.22.1 # Using Node.js 12 image
    steps:
      - checkout

      # Install dependencies (adjust based on your build process)
      - run:
          name: Install Dependencies
          command: yarn install # Assuming you use yarn, adjust if needed

      # Define build commands based on branch using switch statement
      - run:
          name: Build Application
          command: |
            case "$CIRCLE_BRANCH" in
              feature/*)
                echo "Building for feature branch..."
                yarn build:netlify
                ;;
              fix/*)
                echo "Building for fix branch..."
                yarn build:netlify
                ;;
              dev)
                echo "Building for dev branch..."
                yarn build:staging
                ;;
              main)
                echo "Building for main branch..."
                yarn build:prod
                ;;
              *)
                echo "Branch not recognized. Skipping build."
                ;;
            esac

  # Netlify Deployment (Draft Preview) - Feature/Fix Branch Only
  deploy-to-netlify:
    docker:
      - image: node:latest # Assuming a basic Node.js image for Netlify CLI
    steps:
      - run:
          name: Install Netlify CLI
          command: npm install -g netlify-cli

      # Login to Netlify (replace with access token)
      - run:
          name: Login to Netlify
          command: netlify login -e YOUR_NETLIFY_ACCESS_TOKEN

      # Deploy contents of dist folder using draft flag
      # Consider using environment variables for Netlify site ID per branch type (optional)
      - run:
          name: Deploy to Netlify (Draft Preview)
          command: netlify deploy -d -s YOUR_NETLIFY_FEATURE_SITE_ID dist/*


  # Server Deployment (using rsync) - Dev/Main Branch Only
  deploy-to-staging-or-production:
    docker:
      - image: alpine:latest # Using a minimal image for rsync
    steps:
      - run:
          name: Deploy to Production (Dev/Main)
          command: |
            # Deploy using rsync (replace with your details)
            rsync -avz \
                 --exclude='.git*' \
                 dist/ your_user@your_server:/path/to/destination/

workflows:
  version: 2.0
  build-and-deploy-for-feature-or-fix:
    when:
      or:
        - \<< pipeline.git.branch =~ /^feature\//  # Regex for feature/ branches
        - \<< pipeline.git.branch =~ /^fix\//     # Regex for fix/ branches
    jobs:
      - build
      - deploy-to-netlify:
          requires:
            - build
          
  build-and-deploy-to-staging:
    when:
      and:
        - equal: [ dev, << pipeline.git.branch >> ]
    jobs:
      - build
      - deploy-to-staging-or-production:
          requires:
            - build
          

  build-and-deploy-to-production:
    when:
      and:
        - equal: [ main, << pipeline.git.branch >> ]
    jobs:
      - build
      - deploy-to-staging-or-production:
          requires:
            - build
          

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests