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

Shell-style && concatenation is fragile (GitLab, Bitbucket) #144

Open
bittner opened this issue Jun 22, 2020 · 2 comments
Open

Shell-style && concatenation is fragile (GitLab, Bitbucket) #144

bittner opened this issue Jun 22, 2020 · 2 comments
Labels

Comments

@bittner
Copy link
Member

bittner commented Jun 22, 2020

Both in GitLab CI and Bitbucket Pipelines the shell-style && concatenation seems to be very fragile and doesn't behave as expected.

Expected behavior

When a single command fails in the chain of commands concatenated with && then the entire pipeline should fail, and abort immediately.

Actual behavior

When a single command fails in a block with pushd ... && kustomize edit ... && popd ... then the pipeline continues with the next step, which consequently fails again, but even there without making the entire pipeline fail.

Examples (related failing builds)

@bittner bittner added the bug label Jun 22, 2020
@bittner
Copy link
Member Author

bittner commented Jun 22, 2020

The fragility might result from the piped kustomize command in the command chain:

kustomize build | oc apply -f - && ...

When kustomize fails its exit status is not evaluated by && but the one of oc apply.

@bittner
Copy link
Member Author

bittner commented Sep 2, 2020

Piping in shells is always problematic in pipelines. A simple, innocent example is what we use to pull existing Docker image layers (something that is suggested in the GitLab docs):

  - docker pull "${IMAGE}:latest" || true

Looks innocent, doesn't it? – If the image doesn't exist yet it would error out, hence we fall back to true.

So, what's the problem? – What if we don't have permissions to push, pull, etc.? docker login worked on the line above, but this line should fail now. And it won't. It will continue to the next statements and produce potentially confusing errors that need to be troubleshot. There must be a better way.™️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant