Tony Dev
Tony Dev

Reputation: 11

Bitbucket pipeline fails for grep command in exclude hidden directory

I have the following command to run:

grep -r -n --exclude-dir='.test' ERROR . >> errors.txt

This works fine on the terminal but when I run this on bitbucket pipeline via yml file, it fails with the error:

grep: unrecognized option: exclude-dir=.test

Could someone please help figure out the correct syntax?
Thanks

I have tried

grep -r -n --exclude-dir='.test' ERROR . >> errors.txt

and

grep -r -n --exclude-dir=.test ERROR . >> errors.txt

Docker: alpine android github.com/alvr/alpine-android

Upvotes: 0

Views: 164

Answers (2)

Tony Dev
Tony Dev

Reputation: 11

The reason this doesn't work is that alpine images need additional grep upgrade for grep to work properly.

The following works:

script:
    - apk add --no-cache --upgrade grep
    - grep -r -n --exclude-dir='.test' ERROR . >> errors.txt

Upvotes: 0

N1ngu
N1ngu

Reputation: 3824

Alpine images feature different implementations for usual shell tooling. Most of them do not accept long (double dash) options, and some of them feature only a subset of all the options accepted by the regular tooling shipped in non-alpine Linux distributions.

Unless you are using a pipeline runner with a severe hardware disk constraint, I'd suggest you avoid alpine-flavored images for your steps.

Upvotes: 0

Related Questions