Hi all,
I started to have a problem with pull request trigger. I guess there was some change in the end of 2022/beginning 2023 with regards to that.
Originally, I had trigger Pull Request Merged trigger with Pull Request Target brancg set to “/^main$/gi” - so pull requests to main branch triggered build. In this case, CF_BRANCH was set to main. Behavior is different now - CF_BRANCH is set to originator branch. I followed this article to change CF_BRANCH to CF_PULL_REQUEST_TARGET for pull request builds (since article was created on January - I assumed that there was some change in December 2022/January 2023).
Idea there is to cf_export CF_BRANCH variable and set it to CF_PULL_REQUEST_TARGET. As per doc - cf_export must override pipeline level variables:
The variables exported with cf_export overrides those at the pipeline-level.
However, it looks like CF_BRANCH is modified to exported value only at command level of step, i.e.:
steps:
stepname:
type: freestyle
arguments:
image: 'alpine:3.8'
commands:
- echo $CF_EXPORT
But at step level - CF_BRANCH is still not changed (originator of PR request), i.e.:
steps:
clone:
title: "Cloning repository"
type: "git-clone"
repo: "repo/name"
revision: ${{CF_BRANCH}}
So in first case, CF_BRANCH=CF_PULL_REQUEST_TARGET, in second - CF_BRANCH=ORIGINATOR_OF_PR.
I ended up following this article (remove underscore in front of support):
https://_support.codefresh.io/hc/en-us/articles/360017253059-How-to-Set-branch-for-build-depending-on-whether-it-s-a-push-or-PR-event)
which suggests to cf_export new variable name with targer branch name for PR requests and using this new variable name in all clone and etc. steps.
Have anyone encountered this or I am missing something? I have a feeling that doc reference - overrides those at the pipeline-level - is explicitly means pipiline variables and is not impacting trigger variables (what CF_BRANCH is).
In addition, all branch conditions are also tied originator of PR request meaning branch condition like this will return false for PR request to main branch build:
steps
stepname:
when:
branch:
ignore:
- main
But I guess this might be expected.
Thank in advance.