Whenever a feature needs to be deployed to en environment a PR is created. To complete this PR some builds need to be validated first. Only when this is done we can complete the PR.
After the PR is completed and merged. A Build is triggered on the target (environment) branch. This will deploy the changes.
After to completion and merge of the PR build is triggered that will take the last changes through git diff and deploy it. I take the last changes through this command
$ git diff --name-only --diff-filter=d HEAD^ HEAD
Whenever this is executed I receive the following error.
fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' ##[error]Bash exited with code '128'.
But after that I trigger the build manually and then the git diff works and the deploy happens smoothly.
Why does it give an error when it is automatically triggered through a commit on the target (environment) branch, and why does it work when I trigger it manually?
These are the commands I already tried, without success
$ git log -1 –name-only –oneline
$ git diff –name-only –diff-filter=d HEAD^ HEAD
$ git diff –name-only –diff-filter= @[email protected]
New pipelines created after the September 2022 Azure DevOps sprint 209 update have Shallow fetch enabled by default and configured with a depth of 1. If your repository is large, this option might make your build pipeline more efficient.
You can configure the Shallow fetch setting from the properties of the Get sources task in your pipeline. Like increase the depth to 5. Refer to Shallow fetch for more information.
Answered By – Suki Ji-MSFT
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0