[SOLVED] Bitbucket pipeline fails for grep command in exclude hidden directory
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
Answered By — Tony Dev
Answer Checked By — Willingham (FixIt Volunteer)
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0
메타데이터
- post_id
- d5ea33d47908
- slug
- solved-bitbucket-pipeline-fails-for-grep-command-in-exclude-hidden-directory-d5ea33d47908
- url
- https://medium.com/@fixitblog/solved-bitbucket-pipeline-fails-for-grep-command-in-exclude-hidden-directory-d5ea33d47908
- canonical_url
- https://medium.com/@fixitblog/solved-bitbucket-pipeline-fails-for-grep-command-in-exclude-hidden-directory-d5ea33d47908
- author_url
- https://medium.com/@fixitblog
- status
- ok
- fetched_at
- 2026-08-01 17:22:33