Im trying to make my first build on aws and this is my buildspec.yml
, I was just testing if my command does work on codebuild
version: 0.2
env:
git-credential-helper: yes
phases:
install:
runtime-versions:
nodejs: 16
pre_build:
commands:
- aws codeartifact login ...
build:
commands:
- changed_folders=$(git diff --dirstat=files,0 HEAD~1 | awk '{print $2}' | xargs -I {} dirname {} | awk -F '/' '{print $1}' | sort | uniq)
- echo $changed_folders
this command works on local but when it is building
git diff --dirstat=files,0 HEAD~1 | awk '{print $2}' | xargs -I {} dirname {} | awk -F '/' '{print $1}' | sort | uniq
theres an error saying
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
I tried changing the HEAD~1
with $CODEBUILD_WEBHOOK_HEAD_REF
it works but im getting an empty result when I echo using echo $changed_folders
Im using github as my repository
Reference: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html