Change image mirror pipeline to image update+mirror
This commit is contained in:
Родитель
45e08850a0
Коммит
b2210703c5
|
@ -5,6 +5,16 @@ parameters:
|
|||
- name: Images
|
||||
type: object
|
||||
default:
|
||||
- source: azsdkengsys.azurecr.io/stress/watcher
|
||||
changes: bash -c "yum update -y"
|
||||
- source: azsdkengsys.azurecr.io/stress/deploy-test-resources
|
||||
changes: bash -c "yum update -y"
|
||||
- source: azsdkengsys.azurecr.io/stress/httpfaultinjector
|
||||
changes: bash -c "yum update -y"
|
||||
- source: azsdkengsys.azurecr.io/stress/otelcollector
|
||||
changes: bash -c "apt update -y && apt upgrade -y"
|
||||
- source: ghcr.io/chaos-mesh/chaos-daemon:v2.6.3
|
||||
changes: bash -c "apt update -y && apt upgrade -y"
|
||||
- source: ghcr.io/chaos-mesh/chaos-daemon:v2.6.3
|
||||
mirror: azsdkengsys.azurecr.io/mirror/chaos-mesh/chaos-daemon:v2.6.3
|
||||
changes: bash -c "apt update -y && apt upgrade -y"
|
||||
|
@ -22,12 +32,12 @@ extends:
|
|||
parameters:
|
||||
stages:
|
||||
- stage:
|
||||
displayName: Mirror Images
|
||||
displayName: Update Images
|
||||
variables:
|
||||
- template: /eng/pipelines/templates/variables/image.yml
|
||||
jobs:
|
||||
- job: MirrorImages
|
||||
displayName: Mirror Container Images
|
||||
- job: UpdateImages
|
||||
displayName: Update Container Images
|
||||
|
||||
pool:
|
||||
name: $(LINUXPOOL)
|
||||
|
@ -37,24 +47,27 @@ extends:
|
|||
steps:
|
||||
- ${{ each image in parameters.Images }}:
|
||||
- task: AzureCLI@2
|
||||
displayName: Login to ${{ split(image.mirror, '.')[0] }}
|
||||
${{ if image.mirror }}:
|
||||
displayName: Login to ${{ split(image.mirror, '.')[0] }}
|
||||
${{ else }}:
|
||||
displayName: Login to ${{ split(image.source, '.')[0] }}
|
||||
inputs:
|
||||
azureSubscription: "Azure SDK Engineering System"
|
||||
scriptType: pscore
|
||||
scriptLocation: inlineScript
|
||||
inlineScript: |
|
||||
az acr login --name ${{ split(image.mirror, '.')[0] }}
|
||||
${{ if image.mirror }}:
|
||||
inlineScript: az acr login --name ${{ split(image.mirror, '.')[0] }}
|
||||
${{ else }}:
|
||||
inlineScript: az acr login --name ${{ split(image.source, '.')[0] }}
|
||||
- task: Powershell@2
|
||||
displayName: Mirror ${{ image.source }} to ${{ image.mirror }}
|
||||
${{ if image.mirror }}:
|
||||
displayName: Mirror ${{ image.source }} to ${{ image.mirror }}
|
||||
${{ else }}:
|
||||
displayName: Update ${{ image.source }}
|
||||
inputs:
|
||||
pwsh: true
|
||||
filePath: $(Build.SourcesDirectory)/eng/scripts/mirror-container-image.ps1
|
||||
${{ if image.changes }}:
|
||||
arguments: >
|
||||
-Image ${{ image.source }}
|
||||
-Mirror ${{ image.mirror }}
|
||||
-changes '${{ image.changes }}'
|
||||
${{ else }}:
|
||||
arguments: >
|
||||
-Image ${{ image.source }}
|
||||
-Mirror ${{ image.mirror }}
|
||||
filePath: $(Build.SourcesDirectory)/eng/scripts/update-container-image.ps1
|
||||
arguments: >
|
||||
-Image '${{ image.source }}'
|
||||
-Mirror '${{ coalesce(image.mirror, "") }}'
|
||||
-Changes '${{ coalesce(image.changes, "") }}'
|
|
@ -10,7 +10,7 @@ param(
|
|||
$ErrorActionPreference = 'Stop'
|
||||
$PSNativeCommandUseErrorActionPreference = $true
|
||||
|
||||
if ($RegistryLogin) {
|
||||
if ($RegistryLogin -and $Mirror) {
|
||||
$mirrorRegistry = $Mirror.Split('.')[0]
|
||||
Write-Host "Logging in to $mirrorRegistry"
|
||||
az acr login -n $mirrorRegistry
|
||||
|
@ -18,17 +18,22 @@ if ($RegistryLogin) {
|
|||
|
||||
Write-Host "docker pull $Image"
|
||||
docker pull $Image
|
||||
Write-Host "docker tag $Image $Mirror"
|
||||
docker tag $Image $Mirror
|
||||
|
||||
$target = $Image
|
||||
if ($Mirror) {
|
||||
Write-Host "docker tag $Image $Mirror"
|
||||
docker tag $Image $Mirror
|
||||
$target = $Mirror
|
||||
}
|
||||
|
||||
if ($Changes) {
|
||||
$cmd = "docker run $Mirror $Changes"
|
||||
$cmd = "docker run $target $Changes"
|
||||
Write-Host $cmd
|
||||
Invoke-Expression $cmd
|
||||
$output = docker ps -al --format json | ConvertFrom-Json
|
||||
Write-Host "docker commit $($output.ID) $Mirror"
|
||||
docker commit $output.ID $Mirror
|
||||
Write-Host "docker commit $($output.ID) $target"
|
||||
docker commit $output.ID $target
|
||||
}
|
||||
|
||||
Write-Host "docker push $Mirror"
|
||||
docker push $Mirror
|
||||
Write-Host "docker push $target"
|
||||
docker push $target
|
Загрузка…
Ссылка в новой задаче