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
|
|
|
|
parameters:
|
|
|
|
- name: arch
|
|
|
|
type: string
|
|
|
|
values:
|
|
|
|
- amd64
|
|
|
|
- armhf
|
|
|
|
- arm64
|
2022-09-21 02:50:30 -05:00
|
|
|
- name: march
|
|
|
|
type: string
|
|
|
|
default: ''
|
2021-11-06 05:42:51 -05:00
|
|
|
- name: dist
|
|
|
|
type: string
|
|
|
|
values:
|
2023-06-26 11:14:51 -05:00
|
|
|
- bookworm
|
2021-11-06 05:42:51 -05:00
|
|
|
- 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:
|
2022-12-27 01:40:15 -06:00
|
|
|
- job: sonic_slave_${{ parameters.dist }}${{ parameters.march }}
|
2021-11-06 05:42:51 -05:00
|
|
|
timeoutInMinutes: 360
|
2022-09-21 02:50:30 -05:00
|
|
|
variables:
|
2022-09-22 23:54:57 -05:00
|
|
|
- template: /.azure-pipelines/template-variables.yml@buildimage
|
|
|
|
- template: /.azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
|
2021-11-06 05:42:51 -05:00
|
|
|
pool: ${{ parameters.pool }}
|
|
|
|
steps:
|
|
|
|
- template: cleanup.yml
|
2022-09-22 23:54:57 -05:00
|
|
|
- template: /.azure-pipelines/template-clean-sonic-slave.yml@buildimage
|
2021-11-06 05:42:51 -05:00
|
|
|
- checkout: self
|
|
|
|
clean: true
|
2022-09-21 02:50:30 -05:00
|
|
|
- task: Docker@2
|
|
|
|
displayName: Login to ACR
|
|
|
|
inputs:
|
|
|
|
command: login
|
|
|
|
containerRegistry: ${{ parameters.registry_conn }}
|
2021-11-06 05:42:51 -05:00
|
|
|
- bash: |
|
|
|
|
set -ex
|
2023-01-08 23:27:15 -06:00
|
|
|
build_options="$(VERSION_CONTROL_OPTIONS)"
|
|
|
|
image_tag=$(BLDENV=${{ parameters.dist }} make -f Makefile.work showtag $build_options PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} | grep sonic-slave | tail -n 1)
|
2022-09-21 02:50:30 -05:00
|
|
|
image_latest=$(echo $(echo $image_tag | awk -F: '{print$1}'):latest)
|
2022-12-27 01:40:15 -06:00
|
|
|
if echo ${{ parameters.pool }} | grep ${{ parameters.arch }};then
|
|
|
|
image_latest=$(echo ${image_latest} | sed 's/:/-${{ parameters.arch }}:/')
|
|
|
|
fi
|
2022-12-27 20:56:50 -06:00
|
|
|
image_branch=$(echo $(echo $image_latest | awk -F: '{print$1}'):$(Build.SourceBranchName))
|
2022-09-21 02:50:30 -05:00
|
|
|
docker rmi $image_tag || true
|
2021-11-06 05:42:51 -05:00
|
|
|
|
2022-09-21 02:50:30 -05:00
|
|
|
if [[ "$(Build.Reason)" =~ [a-zA-Z]*CI ]] && docker pull ${{ parameters.registry_url }}/${image_tag};then
|
|
|
|
exit 0
|
2021-11-06 05:42:51 -05:00
|
|
|
fi
|
|
|
|
|
2023-01-08 23:27:15 -06:00
|
|
|
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ parameters.dist }} make -f Makefile.work configure $build_options PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} $args || docker image ls $image_tag
|
2022-09-21 02:50:30 -05:00
|
|
|
if [[ "$(Build.Reason)" == "PullRequest" ]];then
|
|
|
|
exit 0
|
2021-11-06 05:42:51 -05:00
|
|
|
fi
|
|
|
|
|
2022-09-21 02:50:30 -05:00
|
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag}
|
|
|
|
docker push ${REGISTRY_SERVER}/${image_tag}
|
2022-12-25 20:35:15 -06:00
|
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_branch}
|
|
|
|
docker push ${REGISTRY_SERVER}/${image_branch}
|
2022-12-27 01:40:15 -06:00
|
|
|
if [[ "$(Build.SourceBranchName)" == "master" ]];then
|
2022-09-21 02:50:30 -05:00
|
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest}
|
|
|
|
docker push ${REGISTRY_SERVER}/${image_latest}
|
2022-03-30 01:43:51 -05:00
|
|
|
fi
|
2021-11-06 05:42:51 -05:00
|
|
|
env:
|
|
|
|
REGISTRY_SERVER: ${{ parameters.registry_url }}
|
|
|
|
displayName: Build sonic-slave-${{ parameters.dist }}-${{ parameters.arch }}
|