Hi,
I am experimenting with Starlark to implement a conditional around whether the build event is a push or a pull request and what branches are involved.
I have the following in the pipeline code:
if ctx.build.event == "pull_request":
return ctx.build.target
if ctx.build.branch in ["master"] or ctx.build.branch.startswith("release"):
return ctx.build.branch
return "develop
In case of a pull request the result of this condition is inconsistent.
I have a pull request open from a feature branch (feature/) into an epic branch (epic/).
I would expect the above condition to return ctx.build.target since the event is a pull request and that the return value should be the epic branch since that is the target.
Restarting the same build which was kicked off by said pull request the condition above sometimes returns the source branch which seems quite impossible to me, unless the ctx.build.target property stores the source branch rather than the target.
In other cases it just falls through and returns the fallback develop value which makes me believe that the build event is wrongly contains push.
May I ask the community’s help in confirming that my condition is valid and should work?
Any help in debugging this situation would be greatly appreciated.