diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-07-31 22:17:22 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-08-03 17:47:24 +0300 |
commit | 32b88294d5a3b7bc22682c7942d8b3c4fa1502c6 (patch) | |
tree | 147f76186d6307c4ef80d477333f4f6c151f2f0d /app | |
parent | cb2e07309b4e61501a44c3568155bdb73252338f (diff) |
Allow multiple JIRA transition ids
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_services/jira_service.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index 412d62388f0..82d438d5378 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -8,6 +8,10 @@ class JiraService < IssueTrackerService validates :username, presence: true, if: :activated? validates :password, presence: true, if: :activated? + validates :jira_issue_transition_id, + format: { with: Gitlab::Regex.jira_transition_id_regex, message: "transition ids can have only numbers which can be split with , or ;" }, + allow_blank: true + prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id, :title, :description before_update :reset_password @@ -91,7 +95,7 @@ class JiraService < IssueTrackerService { type: 'text', name: 'api_url', title: 'JIRA API URL', placeholder: 'If different from Web URL' }, { type: 'text', name: 'username', placeholder: '', required: true }, { type: 'password', name: 'password', placeholder: '', required: true }, - { type: 'text', name: 'jira_issue_transition_id', title: 'Transition ID', placeholder: '' } + { type: 'text', name: 'jira_issue_transition_id', title: 'Transition ID(s)', placeholder: 'Use , or ; to separate multiple transition IDs' } ] end @@ -191,8 +195,18 @@ class JiraService < IssueTrackerService end end + # jira_issue_transition_id can have multiple values split by , or ; + # the issue is transitioned at the order given by the user + # if any transition fails it will log the error message and stop the transition sequence def transition_issue(issue) - issue.transitions.build.save(transition: { id: jira_issue_transition_id }) + jira_issue_transition_id.scan(Gitlab::Regex.jira_transition_id_regex).each do |transition_id| + begin + issue.transitions.build.save!(transition: { id: transition_id }) + rescue => error + Rails.logger.info "#{self.class.name} Issue Transition failed message ERROR: #{client_url} - #{error.message}" + return false + end + end end def add_issue_solved_comment(issue, commit_id, commit_url) |