terminalgrepyamlbitbucket-pipelineshidden-files

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


Solution

  • 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