sonic-buildimage/.azure-pipelines/docker-sonic-slave-template.yml

79 lines
2.4 KiB
YAML

# 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
parameters:
- name: arch
type: string
values:
- amd64
- armhf
- arm64
- name: march
type: string
default: ''
- 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.march }}${{ parameters.arch }}
timeoutInMinutes: 360
variables:
- template: /.azure-pipelines/template-variables.yml@buildimage
- template: /.azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
pool: ${{ parameters.pool }}
steps:
- template: cleanup.yml
- template: /.azure-pipelines/template-clean-sonic-slave.yml@buildimage
- checkout: self
clean: true
submodules: recursive
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: ${{ parameters.registry_conn }}
- bash: |
set -ex
image_tag=$(BLDENV=${{ parameters.dist }} make -f Makefile.work showtag PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} | grep sonic-slave | tail -n 1)
image_latest=$(echo $(echo $image_tag | awk -F: '{print$1}'):latest)
docker rmi $image_tag || true
if [[ "$(Build.Reason)" =~ [a-zA-Z]*CI ]] && docker pull ${{ parameters.registry_url }}/${image_tag};then
exit 0
fi
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ parameters.dist }} make -f Makefile.work configure PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} $args || docker image ls $image_tag
if [[ "$(Build.Reason)" == "PullRequest" ]];then
exit 0
fi
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag}
docker push ${REGISTRY_SERVER}/${image_tag}
if [[ "${{ parameters.arch }}" == "amd64" ]];then
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest}
docker push ${REGISTRY_SERVER}/${image_latest}
fi
env:
REGISTRY_SERVER: ${{ parameters.registry_url }}
displayName: Build sonic-slave-${{ parameters.dist }}-${{ parameters.arch }}