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

Unexpected behaviour when mixing depends_on and branches #1453

Open
lazycodeninja opened this issue Apr 11, 2022 · 3 comments
Open

Unexpected behaviour when mixing depends_on and branches #1453

lazycodeninja opened this issue Apr 11, 2022 · 3 comments

Comments

@lazycodeninja
Copy link

I'm trying to construct a CI/CD pipeline that should build for all Git branches, publish an artifact only for the main branch, and deploy if an artifact was published, e.g.

  - command: ./gradlew build
    key: build

  - command: ./gradlew jib
    key: publish
    branches: "main"

  - command: deploy.sh
    key: deploy
    depends_on: publish

What I've found is that the deploy step executes even though the publish step does not. Worse, if the publish step isn't even defined, the deploy step still runs, e.g.

  - command: ./gradlew build
    key: build

#  - command: ./gradlew jib
#   key: publish
#    branches: "main"

  - command: deploy.sh
    key: deploy
    depends_on: publish

I haven't tried the if property so I don't know if it works the same way as branches, but I wouldn't expect this to be the behaviour for depends_on`. I would expect the step to fail, or at worse, wait indefinitely.

@plaindocs
Copy link
Contributor

Hey @lazycodeninja

When you use branches the steps are removed entirely from branches that do not match. So if you add an identical branches key to your Deploy step as well, it should work as intended.

I'll take a look at the docs for what happens when there is no dependency, and see if we can make that more clear.

@lazycodeninja
Copy link
Author

When you use branches the steps are removed entirely from branches that do not match.

So then how does a subsequent step trigger if its dependency never triggers?

So if you add an identical branches key to your Deploy step as well, it should work as intended.

Yeah, that's what I'm doing but it means doing so for every deploy step (there are several in a group, and I don't see depends_on as an option for the group step). And if someone misunderstands the semantics and adds a new deploy step in future it means an accidental deployment because this behaviour "fails open".

I feel like this is incorrect behaviour more than a docs issue, should I just email support?

@plaindocs
Copy link
Contributor

I think that makes sense, drop them a line and they will be happy to help.

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

No branches or pull requests

2 participants