diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index 0b033e9593..c84c914418 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -132,3 +132,4 @@ jobs: make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).bin fi displayName: "Build sonic image" + - template: check-dirty-version.yml diff --git a/.azure-pipelines/check-dirty-version.yml b/.azure-pipelines/check-dirty-version.yml new file mode 100644 index 0000000000..5d3909bd28 --- /dev/null +++ b/.azure-pipelines/check-dirty-version.yml @@ -0,0 +1,16 @@ +steps: +- script: | + . functions.sh + SONIC_VERSION=$(sonic_get_version) + echo "SONIC_VERSION=$SONIC_VERSION" + if [[ "$SONIC_VERSION" == *dirty* ]]; then + # Print the detail dirty info + git status --untracked-files=no -s --ignore-submodules + + # Exit with error, if it is a PR build + if [ "$(Build.Reason)" == "PullRequest" ]; then + echo "Build failed for the dirty version: $SONIC_VERSION" 1>&2 + exit 1 + fi + fi + displayName: "Check the dirty version"