From 4cc864eeb554a46e0682a5ab6edf22f7bb9b54fd Mon Sep 17 00:00:00 2001 From: xumia Date: Wed, 22 Feb 2023 00:31:05 +0000 Subject: [PATCH 1/3] [Ci] Support to use the same snapshot for all platform builds --- .../azure-pipelines-UpgrateVersion.yml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index 33f802b0d56c..cdf3dc04b900 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -42,12 +42,31 @@ parameters: - mellanox stages: +- stage: Prepare + jobs: + - job: Prepare + steps: + - script: | + DEFAULT_MIRROR_URL_PREFIX=http://packages.trafficmanager.net + DEBIAN_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian/latest/timestamp) + DEBIAN_SECURITY_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian-security/latest/timestamp) + echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_TIMESTAMP]$DEBIAN_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_SECURITY_TIMESTAMP]$DEBIAN_SECURITY_TIMESTAMP" + name: SetVersions + displayName: 'Set snapshot versions' - stage: Build variables: - name: CACHE_MODE value: none - name: VERSION_CONTROL_OPTIONS value: 'SONIC_VERSION_CONTROL_COMPONENTS=' + - name: SKIP_CHECKOUT + value: true + - name: DEBIAN_TIMESTAMP + value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_TIMESTAMP'] ] + - name: DEBIAN_SECURITY_TIMESTAMP + value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_SECURITY_TIMESTAMP'] ] - template: .azure-pipelines/template-variables.yml@buildimage jobs: - template: azure-pipelines-build.yml @@ -56,6 +75,21 @@ stages: buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} ENABLE_DOCKER_BASE_PULL=n SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y' preSteps: - template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage + - checkout: self + submodules: recursive + fetchDepth: 0 + path: s + displayName: 'Checkout code' + - script: | + echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP" + if [ "$MIRROR_SNAPSHOT" == y ]; then + mkdir -p target/versions/default/ + echo "debian==$DEBIAN_TIMESTAMP" > target/versions/default/versions-mirror + echo "debian-security==$DEBIAN_SECURITY_TIMESTAMP" >> target/versions/default/versions-mirror + cat target/versions/default/versions-mirror + fi + displayName: 'Set snapshot versions' + - stage: UpgradeVersions jobs: - job: UpgradeVersions From 3f75e87984783d7b82b5a92ae4a8c519fad8d038 Mon Sep 17 00:00:00 2001 From: xumia Date: Wed, 22 Feb 2023 00:42:02 +0000 Subject: [PATCH 2/3] Add the stage dependency --- .azure-pipelines/azure-pipelines-UpgrateVersion.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index cdf3dc04b900..d79579302896 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -56,6 +56,7 @@ stages: name: SetVersions displayName: 'Set snapshot versions' - stage: Build + dependsOn: Prepare variables: - name: CACHE_MODE value: none From 8b77119c38fde398e69610fe1f2e3c431243e754 Mon Sep 17 00:00:00 2001 From: xumia Date: Wed, 22 Feb 2023 00:46:35 +0000 Subject: [PATCH 3/3] Add the output attribute --- .azure-pipelines/azure-pipelines-UpgrateVersion.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index d79579302896..1d2a0fbae6dc 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -51,8 +51,8 @@ stages: DEBIAN_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian/latest/timestamp) DEBIAN_SECURITY_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian-security/latest/timestamp) echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP" - echo "##vso[task.setvariable variable=DEBIAN_TIMESTAMP]$DEBIAN_TIMESTAMP" - echo "##vso[task.setvariable variable=DEBIAN_SECURITY_TIMESTAMP]$DEBIAN_SECURITY_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_TIMESTAMP;isOutput=true]$DEBIAN_TIMESTAMP" + echo "##vso[task.setvariable variable=DEBIAN_SECURITY_TIMESTAMP;isOutput=true]$DEBIAN_SECURITY_TIMESTAMP" name: SetVersions displayName: 'Set snapshot versions' - stage: Build