diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index d7f87456f8..b5e5c73228 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -135,9 +135,13 @@ jobs: make $BUILD_OPTIONS ENABLE_ASAN=y target/docker-sonic-vs.gz mv target/docker-sonic-vs.gz target/docker-sonic-vs-asan.gz fi - if [ "$(K8S_OPTIONS)" == 'INCLUDE_KUBERNETES_MASTER=y' ]; then - make $BUILD_OPTIONS $(K8S_OPTIONS) target/sonic-vs.img.gz - mv target/sonic-vs.img.gz target/sonic-vs-k8s.img.gz + if [ "$(K8S_MASTER_CHANGED)" == 'YES' ]; then + make $BUILD_OPTIONS INCLUDE_KUBERNETES_MASTER=y target/sonic-vs.img.gz + gzip -d target/sonic-vs.img.gz + SONIC_RUN_CMDS="qemu-img convert target/sonic-vs.img -O vhdx -o subformat=dynamic target/sonic-vs.vhdx" make $BUILD_OPTIONS sonic-slave-run + gzip target/sonic-vs.vhdx + mv target/sonic-vs.vhdx.gz target/sonic-vs-k8s.vhdx.gz + rm target/sonic-vs.img fi make $BUILD_OPTIONS target/docker-sonic-vs.gz target/sonic-vs.img.gz target/docker-ptf.gz make $BUILD_OPTIONS target/docker-ptf-sai.gz diff --git a/.azure-pipelines/template-skipvstest.yml b/.azure-pipelines/template-skipvstest.yml index ca968d009c..86a2abd1f6 100644 --- a/.azure-pipelines/template-skipvstest.yml +++ b/.azure-pipelines/template-skipvstest.yml @@ -4,11 +4,16 @@ steps: set -ex tar_branch=origin/$(System.PullRequest.TargetBranchName) # Check if k8s master entrance script is changed - if ! git diff $tar_branch..HEAD --name-only | grep -F files/image_config/kubernetes/kubernetes_master_entrance.sh; then - echo "##vso[task.setvariable variable=K8S_OPTIONS;]INCLUDE_KUBERNETES_MASTER=n" - else - echo "##vso[task.setvariable variable=K8S_OPTIONS;]INCLUDE_KUBERNETES_MASTER=y" + K8S_MASTER_CHANGED=NO + if git diff $tar_branch..HEAD --name-only | grep -F files/image_config/kubernetes/kubernetes_master_entrance.sh; then + K8S_MASTER_CHANGED=YES fi + set +x + echo "##vso[task.setvariable variable=K8S_MASTER_CHANGED;]$K8S_MASTER_CHANGED" + displayName: "Check if k8s master image build is needed." + - script: | + set -ex + tar_branch=origin/$(System.PullRequest.TargetBranchName) git diff $tar_branch..HEAD --name-only | grep -v -f .azure-pipelines/vstest-exclude && exit 0 git diff $tar_branch..HEAD --name-only | grep -f .azure-pipelines/vstest-include && exit 0 set +x