Just wanted to give a heads up if anyone else was having similar issues - the solution is to use conditional tasks. What we’ve done is to make the plan trigger on PR creation and have a couple of tasks in there which are conditional. The condition being the existance of bamboo.repository.pr.key variable. If it exists within the mvn goal - the analysis is done on the branch. If it doesn’t - the analisys is triggered on the master branch. We have ( somewhat redundantly ) create 2 mvn tasks within our job - one with additional variables as follows:
and another one which doesn’t include those variables. Based on the existance of bamboo.repository.pr.key variable within the goal, SQ executes the analysis. Since we have both tasks in our job, every time we create a pull request, the reuslting analysis is as follows:
- the task which includes the variable in the condition is executed, therefore the branch is analized
- the task which does not include the variable in the condition is executed, therefor the master branch is analized.
That is where the “somehat redundancy” comes from - we analize the master branch every time, which shouldn’t really be neccesarry ( after the branches merge ), so we have disabled that particular task from our job.