From 5b9c72360371476c185d364bb825ea0ce687f99d Mon Sep 17 00:00:00 2001 From: Sachin Holla Date: Thu, 28 Sep 2023 14:39:20 +0530 Subject: [PATCH] Download only required artifacts during pipeline build * Download only libyang*.deb and sonic_yang_models*.whl to save space * Download artifacts from current branch's latest vs build * Enable pipeline builds for 202x branches --- azure-pipelines.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dd9434102b..e6ff8839c9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,11 +7,20 @@ trigger: branches: include: - master + - 202??? pr: branches: include: - master + - 202??? + +variables: + - name: BUILD_BRANCH + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + value: $(System.PullRequest.TargetBranch) + ${{ else }}: + value: $(Build.SourceBranchName) resources: repositories: @@ -19,6 +28,7 @@ resources: type: github name: sonic-net/sonic-mgmt-common endpoint: sonic-net + ref: refs/heads/$(BUILD_BRANCH) stages: - stage: Build @@ -42,16 +52,19 @@ stages: - checkout: sonic-mgmt-common clean: true submodules: recursive - displayName: 'Checkout code' + displayName: 'Checkout sonic-mgmt-common' - task: DownloadPipelineArtifact@2 inputs: source: specific project: build - pipeline: 1 + pipeline: 142 artifact: sonic-buildimage.vs runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' + runBranch: 'refs/heads/$(BUILD_BRANCH)' + patterns: | + target/debs/buster/libyang*.deb + target/python-wheels/bullseye/sonic_yang_models*.whl displayName: "Download sonic buildimage" - script: | @@ -78,18 +91,21 @@ stages: [[ ! -f python3_requirements.txt ]] || \ sudo pip3 install --no-cache-dir -r python3_requirements.txt - popd + displayName: "Install dependency" + + - script: | + sudo pip3 install ../target/python-wheels/bullseye/sonic_yang_models-1.0-py3-none-any.whl + displayName: "Install sonic yangs" + - script: | + set -ex pushd sonic-mgmt-common NO_TEST_BINS=1 dpkg-buildpackage -rfakeroot -b -us -uc -j$(nproc) - - displayName: "Install dependency" + displayName: "Build sonic-mgmt-common" - script: | set -ex - ls -l - pushd sonic-mgmt-framework dpkg-buildpackage -rfakeroot -us -uc -b -j$(nproc) && cp ../*.deb $(Build.ArtifactStagingDirectory)/