This commit is contained in:
parent
82f4a2628b
commit
5db68009ad
@ -3,26 +3,36 @@
|
||||
# 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
|
||||
resources:
|
||||
repositories:
|
||||
- repository: buildimage
|
||||
type: github
|
||||
name: sonic-net/sonic-buildimage
|
||||
ref: master
|
||||
endpoint: sonic-net
|
||||
|
||||
schedules:
|
||||
- cron: "0 8 * * *"
|
||||
- cron: "0 0 * * 0"
|
||||
displayName: Weekly build
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- 202012
|
||||
- 202???
|
||||
always: true
|
||||
|
||||
trigger: none
|
||||
pr:
|
||||
pr: none
|
||||
trigger:
|
||||
batch: true
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- 202???
|
||||
paths:
|
||||
include:
|
||||
- sonic-slave-jessie
|
||||
- sonic-slave-stretch
|
||||
- sonic-slave-buster
|
||||
- src/sonic-build-hooks
|
||||
- sonic-slave-*
|
||||
- files/build/versions
|
||||
- Makefile
|
||||
- Makefile.work
|
||||
|
||||
parameters:
|
||||
- name: 'arches'
|
||||
@ -34,6 +44,7 @@ parameters:
|
||||
- name: 'dists'
|
||||
type: object
|
||||
default:
|
||||
- bullseye
|
||||
- buster
|
||||
- stretch
|
||||
- jessie
|
||||
@ -44,70 +55,29 @@ parameters:
|
||||
type: string
|
||||
default: sonicdev
|
||||
|
||||
variables:
|
||||
- ${{ if eq(variables['Build.SourceBranchName'], '202012') }}:
|
||||
- name: BUILD_OPTIONS
|
||||
value: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
|
||||
|
||||
stages:
|
||||
- stage: Build
|
||||
- stage: Build_in_amd64
|
||||
jobs:
|
||||
- ${{ each dist in parameters.dists }}:
|
||||
- ${{ if endswith(variables['Build.DefinitionName'], dist) }}:
|
||||
- ${{ each arch in parameters.arches }}:
|
||||
- job: Build_${{ dist }}_${{ arch }}
|
||||
timeoutInMinutes: 360
|
||||
pool: sonicbld
|
||||
steps:
|
||||
- template: cleanup.yml
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: recursive
|
||||
- bash: |
|
||||
set -ex
|
||||
|
||||
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
|
||||
|
||||
SLAVE_DIR=sonic-slave-${{ dist }}
|
||||
if [ x${{ arch }} == x"amd64" ]; then
|
||||
SLAVE_BASE_IMAGE=${SLAVE_DIR}
|
||||
else
|
||||
SLAVE_BASE_IMAGE=${SLAVE_DIR}-march-${{ arch }}
|
||||
fi
|
||||
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
echo ${{ arch }} > .arch
|
||||
|
||||
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ 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:latest
|
||||
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG
|
||||
set +x
|
||||
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_IMAGE]$SLAVE_BASE_IMAGE"
|
||||
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_TAG]$SLAVE_BASE_TAG"
|
||||
env:
|
||||
REGISTRY_SERVER: ${{ parameters.registry_url }}
|
||||
displayName: Build sonic-slave-${{ dist }}-${{ 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
|
||||
- template: .azure-pipelines/docker-sonic-slave-template.yml@buildimage
|
||||
parameters:
|
||||
pool: sonicbld
|
||||
arch: ${{ arch }}
|
||||
dist: ${{ dist }}
|
||||
${{ if ne(arch, 'amd64') }}:
|
||||
march: _march_${{ arch }}
|
||||
- stage: Build_native_arm
|
||||
dependsOn: []
|
||||
jobs:
|
||||
- ${{ each dist in parameters.dists }}:
|
||||
- ${{ if endswith(variables['Build.DefinitionName'], dist) }}:
|
||||
- ${{ each arch in parameters.arches }}:
|
||||
- ${{ if ne(arch, 'amd64') }}:
|
||||
- template: .azure-pipelines/docker-sonic-slave-template.yml@buildimage
|
||||
parameters:
|
||||
pool: sonicbld-${{ arch }}
|
||||
arch: ${{ arch }}
|
||||
dist: ${{ dist }}
|
||||
march: _${{ arch }}
|
||||
|
Loading…
Reference in New Issue
Block a user