Support automatic transitions of Jira issues, and disabling transitions

Merged Markus Koller requested to merge 322477-jira-issue-transitions into master


This is a follow-up to !53760 (merged) / #16119 (closed), which we had to revert as the automatic transitioning behaviour was causing problems for several users. As discussed in #322477 (closed), we can solve this by adding an explicit setting to enable transitions.

The first commit is unchanged from !53760 (merged) (excluding some minor spec cleanups that we kept in !54807 (merged)) and implements the automatic transitioning, while the second commit adds the new checkbox to toggle transitions.

I also considered splitting up the MR, but it would add a lot of work as we'd have to reverse the order: Add the checkbox to enable transitions first, then add the option for automatic transitions.

What does this MR do?

Add a new setting to the Jira integration to attempt an "automatic" transition of Jira issues, by checking the available workflow transitions on the issue and using the first one with a status category of "Done".

Automatic transitions are enabled by setting the new DB column jira_issue_transition_automatic to true, which takes precedence over the existing jira_issue_transition_id column.

To make this behaviour opt-in, we also introduce an explicit checkbox to enable issue transitions. The state of this checkbox is handled entirely on the frontend, based on the values in jira_issue_transition_id and jira_issue_transition_automatic.



$ rake db:migrate:up VERSION=20210224161552
== 20210224161552 AddJiraIssueTransitionAutomaticToJiraTrackerData: migrating =
-- add_column(:jira_tracker_data, :jira_issue_transition_automatic, :boolean, {:null=>false, :default=>false})
   -> 0.0637s
== 20210224161552 AddJiraIssueTransitionAutomaticToJiraTrackerData: migrated (0.0638s)
$ rake db:migrate:down VERSION=20210224161552
== 20210224161552 AddJiraIssueTransitionAutomaticToJiraTrackerData: reverting =
-- remove_column(:jira_tracker_data, :jira_issue_transition_automatic, :boolean, {:null=>false, :default=>false})
   -> 0.0030s
== 20210224161552 AddJiraIssueTransitionAutomaticToJiraTrackerData: reverted (0.0042s)

Does this MR meet the acceptance criteria?


Availability and Testing


If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Markus Koller