JetBrains automation not start CI with codeReviewOpened trigger

Hello everyone. I wanted to create the automation script configuration that allows to automatically run CI when any code review/ merge request is opened to develop/master branch. My script looks like this:

 

job("Build and run tests") {
    startOn {
    gitPush {
        anyBranchMatching {
            +"master"
            +"develop"
        }
    }
    codeReviewOpened {
        branchToCheckout = CodeReviewBranch.MERGE_REQUEST_SOURCE
    }
}
//other part of the script like failOn and container

I also tried
branchToCheckout = CodeReviewBranch.MERGE_REQUEST_TARGET and default but nothing happens. I did something wrong? 

0
1 comment

Karen Bagratyan Hi,

I have tested your code and jobs are getting triggered on any push to “master” or “develop” branches and if any CR or MR are  opened in any branch. Could you please navigate to the “Jobs → All Runs” tab and ensure the jobs have not been triggered? 

As for the original request, unfortunately, there is no way to filter branches for the “codeReviewOpened” trigger. Jobs will be triggered on any branch where the CR or MR has been opened. However, you might want to use this trigger:

startOn {
    gitPush {
        anyRefMatching {
            +"refs/merge/*/head" // special ref equal to MR source branch, updated on MR updates
        }
    }
}

This triggers the job when a MR is created, and when someone pushes new commits to the MR (including force-push). Please note that it won't work for CR creation. 

If you don't mind, may I ask you for your use case when CI is getting triggered on code review creation? Are there any special cases when CR should be taken into account too? 

0

Please sign in to leave a comment.