[CI] Support 202012 branch generating version files for reproducible build (#7303)

for reproducible build azp

Signed-off-by: Shilong Liu <shilongliu@microsoft.com>
This commit is contained in:
Shilong Liu 2021-04-22 02:06:15 +08:00 committed by GitHub
parent b43c4001f8
commit 8874a2aff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,10 +18,25 @@ pool: sonicbld
stages:
- stage: Build
variables:
CACHE_MODE: none
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS='
jobs:
- template: azure-pipelines-build.yml
parameters:
buildSlave: y
buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y'
preSteps:
- script: |
containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }')
if [ ! -z "$containers" ]; then
docker container kill $containers || true
sleep 5
fi
images=$(docker images 'sonic-slave-*' -a -q)
if [ ! -z "$images" ]; then
docker rmi -f $images
fi
displayName: 'Cleanup sonic slave'
- stage: UpgradeVersions
jobs:
- job: UpgradeVersions
@ -48,11 +63,14 @@ stages:
cp -r $(Pipeline.Workspace)/sonic-buildimage.${default_platform}/versions target/
make freeze FREEZE_VERSION_OPTIONS=-r
find files/build/versions
for artifact in $artifacts
ordered_artifacts=$(echo "$artifacts" | grep -v -E "arm64|armhf" && echo "$artifacts" | grep -E "arm64|armhf")
for artifact in $ordered_artifacts
do
rm -rf target/versions
cp -r $artifact/versions target/
make freeze FREEZE_VERSION_OPTIONS="-a -d"
OPTIONS="-a -d"
[[ "$artifact" == *arm64* || "$artifact" == *armhf* ]] && OPTIONS="-d"
make freeze FREEZE_VERSION_OPTIONS="$OPTIONS"
done
git diff files/build/versions
displayName: 'Freeze Versions'