I am using Azure Pipelines and have the following situation:
I have one repository with the folders A and B (and many more in the future). If I run the pipeline manually, I do chose A or B and the pipeline does stuff with the files in that folder.
This is fine for my branches, but I also want an automatic trigger for my main branch.
How do I get a variable that depends on the path of the code change?
My trigger looks something like this:
trigger:
branches:
include:
- main
paths:
include:
- abc/xyz/A/*
- abc/xyz/B/*
And all I need is a variable that is A or B now, depending on the path where the change occured.
(Ideally if there are changes in both folders the pipeline should trigger twice, but this is the next problem I have to take on)
2
Answers
Here I have mentioned it in the variable section.
There is no direct way to achieve this.
As a work around, you could use git command to get the commit message from the code change in A and B, and set the commit message as variable.
If the changes is from Folder A. Set "FolderAUpdated" to ture
And set conditions to check the variable value
"Custom conditions":
and(succeeded(), eq(variables['FolderAUpdated'], 'true'))
A good option for this would create two individual pipelines, if both folders have changes, two pipelines will be triggered.
Pipeline A
Pipeline B