sonic-buildimage/.azure-pipelines/template-skipvstest.yml
lixiaoyuner cd897b40cc
[ci] Fix and improve k8s master image build process (#18157)
Why I did it
When we change k8s script file to trigger k8s master image build, there's error reported.

/agent/_work/_temp/433f6aca-4fd0-4a79-898e-49d7d0fc7465.sh: line 19: unexpected EOF while looking for matching `''
The main reason is something wrong with passing k8s_options variable(in file template-skipvstest.yml) to build pipeline. Need to fix and improve the passing variable process.

Work item tracking
Microsoft ADO (number only): 25063800
How I did it
Separate the job of checking if k8s image build is needed from skipvstest checking job
Build a VHDX k8s master image for convenient
How to verify it
No error found when k8s master image build is triggered
We have a VHDX k8s master image in the build result.
2024-03-11 14:45:18 +08:00

24 lines
1.0 KiB
YAML

steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- script: |
set -ex
tar_branch=origin/$(System.PullRequest.TargetBranchName)
# Check if k8s master entrance script is changed
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
echo "Skip vstest jobs"
echo "##vso[task.setvariable variable=SKIP_VSTEST;isOutput=true]YES"
name: SetVar
displayName: "Check if vstest is needed."