Merge Hook - Test reports are required

The following scenario assumes that a test report must be created before a new code change can be integrated. The teste report must exists and it must have the correct status.

Common Settings

The common settings of a rule are needed to provide developers information about the configured rule in error situations.

Option

Value

Description

Title

Test report is needed

Is needed to identify the rule in the error messages

Error message

No valid test report has been found for the give code change (issue: %key)

Gives the user further information about the error situation

Hint

Please create for the issue %key% and test report and please ask your team lead to approve the test report.

Gives the user the information about how they can solves the issue.


Page selection based on CQL


Based on the CQL you can identify the test reports you would like to check. In the folder Test-Reports you will find 3 test reports, with different characteristics. This 3 pages are listed in the table above and you will also find examples of how these can be identified by the CQL. However, it is clear that other CQLs may be necessary in your company to identify the corresponding pages. It depends on your page structure. 

Page

Issue key (e.g. commit message)

Identified by Query-Example

Description

New Example Feature - Just for Test Demonstration

DEM-1

label = "%key%" and label = "test-report"

Match the given page, because both labels match

DEM-2 Test Report - Fix of bug 4711

DEM-2

title ~ "%key%" and title ~ "Test Report"

Match the given page, because the page title contains both strings

DEM-3 More Bitbucket hooks

DEM-3

title ~ "%key%" and label = "test-report"

Match the given page, because the page title contains the issue key ant the label "test-report" is given


Skip CQL

Also it should not be allowed to push, if no page has been found by a CQL. For that please ensure, that the option "If no page matches the CQL, the rule will be skipped. The rule will be validated only, if a page has been found." is unset.

Page properties configuration

Now let's evaluate the page properties of the above detected pages. The requested page properties in the hook are for all three pages the same, but the real page properties are different (please check the related pages and you will see).

Page

Merge will be

Issue key (e.g. commit message)

Properties-Example

Description

New Example Feature - Just for Test Demonstration

Accept

DEM-1


Java
issue~%key%
tester+
test-status=tested
approval by=software team lead
approval-status=approved




The merge is allowed, because:

  • the issue key is correct in the page

  • the property tester is not empty

  • the test status is "tested"

  • the approval has been done by the user "software team lead"

  • and the approval-status is "approved"

DEM-2 Test Report - Fix of bug 4711

Reject

DEM-2

The merge will be rejected, because:

  • the test status is in "progress" and not "tested"

  • Nobody has done the approval

  • approval-status is not set

DEM-3 More Bitbucket hooks

Reject

DEM-3

The merge will be rejected, because the approval-status is "needs rework"


Page properties strategy

To have a valid test report all requested properties must match. So it is needed to set the option "All key pairs must match"


Example configuration


settings-test-report.png