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

Global when does not work together with global branches filter [solved] #1941

Closed
5 tasks done
lonix1 opened this issue Jul 7, 2023 · 11 comments
Closed
5 tasks done
Labels
bug Something isn't working

Comments

@lonix1
Copy link
Contributor

lonix1 commented Jul 7, 2023

Component

server

Describe the bug

The docs show an example of a global when with branch condition:

when:
  branch: master

When I tried that, I get an error:

Execution error
failed to parse pipeline: could not apply deprecated branches filter into global when filter

System Info

version "next-b616a822a0-alpine"

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Check that this is a concrete bug. For Q&A join our Discord Chat Server or the Matrix room.
@lonix1 lonix1 added the bug Something isn't working label Jul 7, 2023
@6543
Copy link
Member

6543 commented Jul 7, 2023

witch forge do you use?

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

gitea

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

I just tried the latest version next-45319b24cd-alpine but same result.

@6543
Copy link
Member

6543 commented Jul 7, 2023

this is strange I tested this config and it does exactly what I expect:

when:
    branch: main

steps:
    echo:
        image: bash
        commands: echo ja

I get a pipeline on main but no other branch

@6543
Copy link
Member

6543 commented Jul 7, 2023

what event did you use as trigger?

(mine was a push)

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

Sorry I just test it 10 different ways until I found the problem, and it's me.

when:
  event: push
  branch: master          # <--- I thought the error referred to this
  path: "src/*"

steps:
  build:
    image: alpine
    commands:
      - echo 'hello world'

branches: master          # <--- but it actually referred to this!!!

I think I was looking at the stable and next versions of the docs at the same time! The one is from the old stable and the other is from the next.

Again apologies! 🙏

The "next" version becoming stable is really needed. I'm wathicng that milestone daily! :-)

@lonix1 lonix1 closed this as completed Jul 7, 2023
@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

I think the problem is somestimes when clicking links in the docs, if I'm not careful it redirects to the wrong version. Easy to get confused. I will keep an eye on that and report anything weird.

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

Interesting point though, that is was deprecated. I assume there is no replacement for "global when with branch".

@6543
Copy link
Member

6543 commented Jul 7, 2023

tldr: global when was introduced in next (upcomming v1.0.0) and do deprecate the old global branches filter ...

there is a "migration" running to make transition smoth:

// support deprecated branch filter
if out.BranchesDontUseIt != nil {
if out.When.Constraints == nil {
out.When.Constraints = []constraint.Constraint{{Branch: *out.BranchesDontUseIt}}
} else if len(out.When.Constraints) == 1 && out.When.Constraints[0].Branch.IsEmpty() {
out.When.Constraints[0].Branch = *out.BranchesDontUseIt
} else {
return nil, fmt.Errorf("could not apply deprecated branches filter into global when filter")
}
out.BranchesDontUseIt = nil
}

but you should not use the old and the new ways at the same time ... dont expect magic :D

@6543 6543 changed the title Global when does not support branch Global when does not work together with global branches filter [solved] Jul 7, 2023
@lonix1
Copy link
Contributor Author

lonix1 commented Jul 7, 2023

No of course not, it wasn't an expectation of magic... it was stupidity on my part! ☺️

I discovered the issue BTW, when you go to the docs it always opens the stable version by default. So I have some browser tabs showing stable and some showing next. It's easy to get mixed up, BUT, I should have known better!

@6543
Copy link
Member

6543 commented Jul 7, 2023

#1855 will fix that

@woodpecker-ci woodpecker-ci locked as resolved and limited conversation to collaborators Jul 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants