From c715d22bf98d0a4138f9b77788f2faeffd7ec4ce Mon Sep 17 00:00:00 2001 From: xumia Date: Sat, 2 Apr 2022 10:37:02 +0000 Subject: [PATCH 1/2] [Ci]: check if there is a sonic dirty version issue --- .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 7c312de85931..28fc97ee506a 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -131,3 +131,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 000000000000..9670e9e94091 --- /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" From a50f280fffe3aabc270793d0b2f032005a6b8d11 Mon Sep 17 00:00:00 2001 From: xumia Date: Thu, 7 Apr 2022 14:23:57 +0000 Subject: [PATCH 2/2] Fix comparing any string error --- .azure-pipelines/check-dirty-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/check-dirty-version.yml b/.azure-pipelines/check-dirty-version.yml index 9670e9e94091..5d3909bd280e 100644 --- a/.azure-pipelines/check-dirty-version.yml +++ b/.azure-pipelines/check-dirty-version.yml @@ -3,7 +3,7 @@ steps: . functions.sh SONIC_VERSION=$(sonic_get_version) echo "SONIC_VERSION=$SONIC_VERSION" - if [ "$SONIC_VERSION" == *dirty* ]; then + if [[ "$SONIC_VERSION" == *dirty* ]]; then # Print the detail dirty info git status --untracked-files=no -s --ignore-submodules