From f24a04fa3d2f2ba9993d53a4cb93fc1de87df431 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:49:21 +0800 Subject: [PATCH] [Ci]: check if there is a sonic dirty version issue (#10445) Why I did it [Ci]: check if there is a sonic dirty version issue If there is a dirty version issue in PR build, the build will be failed. --- .azure-pipelines/azure-pipelines-build.yml | 1 + .azure-pipelines/check-dirty-version.yml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .azure-pipelines/check-dirty-version.yml 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"