2021-11-06 05:42:51 -05:00
|
|
|
# Starter pipeline
|
|
|
|
# Start with a minimal pipeline that you can customize to build and deploy your code.
|
|
|
|
# Add steps that build, run tests, deploy, and more:
|
|
|
|
# https://aka.ms/yaml
|
|
|
|
# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
|
2022-03-30 03:01:24 -05:00
|
|
|
resources:
|
|
|
|
repositories:
|
|
|
|
- repository: buildimage
|
|
|
|
type: github
|
2022-08-02 03:15:33 -05:00
|
|
|
name: sonic-net/sonic-buildimage
|
2022-03-30 03:01:24 -05:00
|
|
|
ref: master
|
2022-08-02 03:15:33 -05:00
|
|
|
endpoint: sonic-net
|
2021-11-06 05:42:51 -05:00
|
|
|
|
|
|
|
parameters:
|
|
|
|
- name: arch
|
|
|
|
type: string
|
|
|
|
values:
|
|
|
|
- amd64
|
|
|
|
- armhf
|
|
|
|
- arm64
|
|
|
|
- name: dist
|
|
|
|
type: string
|
|
|
|
values:
|
|
|
|
- bullseye
|
|
|
|
- buster
|
|
|
|
- stretch
|
|
|
|
- jessie
|
|
|
|
- name: registry_url
|
|
|
|
type: string
|
|
|
|
default: sonicdev-microsoft.azurecr.io
|
|
|
|
- name: registry_conn
|
|
|
|
type: string
|
|
|
|
default: sonicdev
|
|
|
|
- name: pool
|
|
|
|
type: string
|
|
|
|
default: sonicbld
|
|
|
|
values:
|
|
|
|
- sonicbld
|
|
|
|
- sonicbld-arm64
|
|
|
|
- sonicbld-armhf
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
- job: Build_${{ parameters.dist }}_${{ parameters.arch }}
|
|
|
|
timeoutInMinutes: 360
|
|
|
|
pool: ${{ parameters.pool }}
|
|
|
|
steps:
|
|
|
|
- template: cleanup.yml
|
2022-04-01 18:48:44 -05:00
|
|
|
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
|
|
|
|
- template: template-clean-sonic-slave.yml
|
|
|
|
- ${{ else }}:
|
|
|
|
- template: .azure-pipelines/template-variables.yml@buildimage
|
2021-11-06 05:42:51 -05:00
|
|
|
- checkout: self
|
|
|
|
clean: true
|
|
|
|
submodules: recursive
|
|
|
|
- bash: |
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
SLAVE_DIR=sonic-slave-${{ parameters.dist }}
|
|
|
|
if [ x${{ parameters.pool }} == x"sonicbld" ]; then
|
|
|
|
if [ x${{ parameters.arch }} == x"amd64" ]; then
|
|
|
|
SLAVE_BASE_IMAGE=${SLAVE_DIR}
|
|
|
|
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}
|
|
|
|
elif [ x${{ parameters.pool }} == x"sonicbld" ]; then
|
|
|
|
SLAVE_BASE_IMAGE=${SLAVE_DIR}-march-${{ parameters.arch }}
|
|
|
|
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-march-${{ parameters.arch }}
|
|
|
|
fi
|
|
|
|
elif [[ x${{ parameters.pool }} == x"sonicbld-armhf" && x${{ parameters.arch }} == x"armhf" ]]; then
|
|
|
|
SLAVE_BASE_IMAGE=${SLAVE_DIR}
|
|
|
|
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-armhf
|
|
|
|
elif [[ x${{ parameters.pool }} == x"sonicbld-arm64" && x${{ parameters.arch }} == x"arm64" ]]; then
|
|
|
|
SLAVE_BASE_IMAGE=${SLAVE_DIR}
|
|
|
|
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-arm64
|
|
|
|
else
|
|
|
|
echo "do not support build ${{ parameters.arch }} on ${{ parameters.pool }}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x"$(Build.SourceBranchName)" == x"202012" ]; then
|
|
|
|
BUILD_OPTIONS = 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
|
|
|
|
fi
|
|
|
|
|
|
|
|
tmpfile=$(mktemp)
|
|
|
|
|
|
|
|
echo ${{ parameters.arch }} > .arch
|
|
|
|
|
|
|
|
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ parameters.dist }} $(BUILD_OPTIONS) make -f Makefile.work sonic-slave-build | tee $tmpfile
|
|
|
|
SLAVE_BASE_TAG=$(grep "^Checking sonic-slave-base image:" $tmpfile | awk -F ':' '{print $3}')
|
|
|
|
SLAVE_TAG=$(grep "^Checking sonic-slave image:" $tmpfile | awk -F ':' '{print $3}')
|
|
|
|
|
|
|
|
mkdir -p target
|
|
|
|
|
|
|
|
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE_UPLOAD:latest
|
|
|
|
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE_UPLOAD:$SLAVE_BASE_TAG
|
|
|
|
set +x
|
|
|
|
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_IMAGE]$SLAVE_BASE_IMAGE_UPLOAD"
|
|
|
|
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_TAG]$SLAVE_BASE_TAG"
|
|
|
|
env:
|
|
|
|
REGISTRY_SERVER: ${{ parameters.registry_url }}
|
|
|
|
displayName: Build sonic-slave-${{ parameters.dist }}-${{ parameters.arch }}
|
|
|
|
|
|
|
|
- task: Docker@2
|
|
|
|
displayName: Upload image
|
|
|
|
inputs:
|
|
|
|
containerRegistry: ${{ parameters.registry_conn }}
|
|
|
|
repository: $(VARIABLE_SLAVE_BASE_IMAGE)
|
|
|
|
command: push
|
|
|
|
tags: |
|
|
|
|
$(VARIABLE_SLAVE_BASE_TAG)
|
|
|
|
latest
|