FR - Github changed files as a trigger payload field
long-term
F
Fawn Antelope
Need the changed file in the payload to be exposed as a harness variable. The reason for the ask is that :
want to create a pipeline that is triggered by a GitHub PR and runs terraform in the folder of the changed file in that PR ( assuming all the changed files are in the same folder).so wanted to get the changed file path using harness variables to tell terraform to run in that path.
Log In
Canny AI
Merged in a post:
Add a construct that will provide the list of changed files in a PR
P
Pink Salamander
While it's possible to filter events by changed files in a pipeline trigger, we would still need to have the list of changed files. This would allow, for example, to conditionally trigger stages/steps.
Currently to get the list we need to perform additional git checkout which is inefficient.
Rohan Gupta
Merged in a post:
Support for excluding multiple files in trigger
F
Far Crane
Hi Team,
We have an requirement to not trigger pipeline in case certain files are changed. We tried to use the event payload expression to exclude some files but this is not good for us, as we have 100+ files to monitor and we cannot add each files in the list, rather if Harness had support for exclude regex, this would help our usecase.
Canny AI
Merged in a post:
Conditions on Changed Files at the stage/step level
F
Frequent Jay
- Support changed files (git diff) at the stage/step conditional level
- Support variables in the file paths (specifically matrix values)
Example:
- stage:
name: Tests
type: CI
strategy:
matrix:
module:
- A
- B
- C
execution:
steps:
- step:
type: Run
name: Test for module <+matrix.module.value>
spec:
shell: Sh
command: echo "Changes in <+matrix.module.value>
N
Nofar Bluestein
When you set a condition on the stage, and the conditional is evaluated so the stage is skipped - it doesn't eat any credits, as they stage never began execution.
In the image i've provided you can see I had 2 stages that were skipped.
Happy to get on a call to go over the suggested solution.
N
Nofar Bluestein
Hey,
referencing a dynamic value coming from the matrix is already supported . for example,
matrix:
submodules: ["a", "b", "c"]
listB: ["some", "random", "list"]
To refer to the elements from listA, you would use the expression <+matrix.submodules>, and to refer to elements from listB, you would use the expression <+matrix.listB>.
I think that what is missing is the we do not currently expose the changed filed as a built in variables available in runtime, which we can keep as an enhancement request.
In the meanwhile, this could be achieved via executing git command and storing the result (changed files) to an output variable, that is populated prior to the matrix execution . then you can set a condition on the stage with the matrix , to skip execution if the diff contains <+matrix.submodules>.
I've created a similar example to convey the idea, see image for how this is evaluated. you can do something similar with 'contains' rather than 'equals' . the conditions are based on JEXL so you have this flexibility.
condition: |
<+matrix.submodules> == <+stages.create_output.spec.execution.steps.Run_1.output.outputVariables.diff_list>
Happy to hear your thought on this suggestion.
Thank ,
Nofar Bluestein,
CI product team
F
Frequent Jay
Nofar Bluestein Thanks for the reply.
> referencing a dynamic value coming from the matrix is already supported
That was not the focus of the post. Git diff is the focus of the post, and the additional specific requirement was that git diff be computed before the matrix, so that we could use the git diff as the matrix itself. I think my example was bad.
> In the meanwhile, this could be achieved via executing git command and storing the result (changed files) to an output variable
That would still require us to initiate a stage and thus eat into our concurrency limit. The goal of this feature to avoid invoking a stage at all if there are no changes to test.
I'm coming from Gitlab CI and this is natively supported:
Rohan Gupta
Hi Andrii, We support this via our Trigger Webhook Activity Page. In the Payload, Harness gets the list of triggering events, within each event we receive from Git we are able to get the commit id this will take you to git to see the diff in the files
Rohan Gupta
long-term
Thanks for your feature request we have added it to our Long Term Roadmap.