On Azure Devops I want to run ".ci/build.yml" pipeline which builds images in "python/version/flavor" folders.
For each version there is a dockerfile and a version.yml which contains my variables (tags in this case). I want all of them to use the same set of files as build context. Files are in the root folder (project-root).
How do I accomplish this in the best way possible?
Folder structure:
project-root/
├── .ci/
│ └── build.yml
│
├── README.md
├── certs.crt
├── config.json
│
└── python/
├── 3.10/
│ └── bookworm/
│ ├── Dockerfile
│ └── version.yml
│
├── 3.11/
│ └── bookworm/
│ ├── Dockerfile
│ └── version.yml
│
└── 3.12/
└── bookworm/
├── Dockerfile
└── version.yml
version.yml example:
variables:
TAG1: python-3.10-bookworm
TAG2: python-3.10-slim-bookworm
Right now, I am like 95% way there. I have this:
trigger: none
parameters:
- name: imageList
type: object
default: ["3.10/bookworm",
"3.11/bookworm",
"3.12/bookworm",
]
stages:
- stage: build
pool: MyLinuxPool
jobs:
- ${{ each image in parameters.imageList }}:
- job: image_${{ replace(replace(replace(image, '-', '_'), '.', '_'), '/', '_') }}
variables:
- template: 'python/${{ image }}/version.yml' < PROBLEM IS HERE
- name: dockerfile
value: 'python/${{ image }}/Dockerfile' < AND HERE
steps:
- task: Docker@2
displayName: Login to ACR
inputs:
containerRegistry: SOME-ACR
command: login
- task: Docker@2
displayName: Build & Push image
inputs:
command: buildAndPush
repository: foo/bar
dockerfile: $(dockerfile)
buildContext: '.'
arguments: '--no-cache'
tags: |
${{ variables.TAG1 }}
${{ variables.TAG2 }}
I know that this works with a simpler folder structure.
The problem is when I run it right now, I get /.ci/build.yml: File /.ci/python/3.10/bookworm/version.yml not found in repository
It starts checking path from .ci folder and not root. How do I change that? I tried experimenting with https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#agent-variables-devops-services but nothings seems to work.