Commit e6f0442e authored by Alex Kalderimis's avatar Alex Kalderimis

Enable synchronization of feature flags to Jira

This enables the synchronization of Feature Flags to Jira, using the
endpoints described at:

  https://developer.atlassian.com/cloud/jira/software/rest/api-group-feature-flags/#api-featureflags-0-1-bulk-post

When a user has enabled the GitLab application in their Jira project,
feature flags will be associated with Jira issues if the Jira issue keys
are mentioned in the feature flag description.
parent 5f5076a0
...@@ -41,7 +41,6 @@ module FeatureFlags ...@@ -41,7 +41,6 @@ module FeatureFlags
def sync_to_jira(feature_flag) def sync_to_jira(feature_flag)
return unless feature_flag.present? return unless feature_flag.present?
return unless Feature.enabled?(:jira_sync_feature_flags, feature_flag.project)
seq_id = ::Atlassian::JiraConnect::Client.generate_update_sequence_id seq_id = ::Atlassian::JiraConnect::Client.generate_update_sequence_id
feature_flag.run_after_commit do feature_flag.run_after_commit do
......
...@@ -14,7 +14,6 @@ module JiraConnect ...@@ -14,7 +14,6 @@ module JiraConnect
feature_flag = ::Operations::FeatureFlag.find_by_id(feature_flag_id) feature_flag = ::Operations::FeatureFlag.find_by_id(feature_flag_id)
return unless feature_flag return unless feature_flag
return unless Feature.enabled?(:jira_sync_feature_flags, feature_flag.project)
::JiraConnect::SyncService ::JiraConnect::SyncService
.new(feature_flag.project) .new(feature_flag.project)
......
---
title: Enable synchronization of feature flags to Jira
merge_request: 51796
author:
type: added
---
name: jira_sync_feature_flags
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50390
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/296990
milestone: '13.8'
type: development
group: group::ecosystem
default_enabled: false
...@@ -33,8 +33,6 @@ module Atlassian ...@@ -33,8 +33,6 @@ module Atlassian
private private
def store_ff_info(project:, feature_flags:, **opts) def store_ff_info(project:, feature_flags:, **opts)
return unless Feature.enabled?(:jira_sync_feature_flags, project)
items = feature_flags.map { |flag| ::Atlassian::JiraConnect::Serializers::FeatureFlagEntity.represent(flag, opts) } items = feature_flags.map { |flag| ::Atlassian::JiraConnect::Serializers::FeatureFlagEntity.represent(flag, opts) }
items.reject! { |item| item.issue_keys.empty? } items.reject! { |item| item.issue_keys.empty? }
......
...@@ -303,24 +303,6 @@ RSpec.describe Atlassian::JiraConnect::Client do ...@@ -303,24 +303,6 @@ RSpec.describe Atlassian::JiraConnect::Client do
expect(response['errorMessages']).to eq(['a: X', 'a: Y', 'b: Z']) expect(response['errorMessages']).to eq(['a: X', 'a: Y', 'b: Z'])
end end
end end
it 'does not call the API if the feature flag is not enabled' do
stub_feature_flags(jira_sync_feature_flags: false)
expect(subject).not_to receive(:post)
subject.send(:store_ff_info, project: project, feature_flags: feature_flags)
end
it 'does call the API if the feature flag enabled for the project' do
stub_feature_flags(jira_sync_feature_flags: project)
expect(subject).to receive(:post).with('/rest/featureflags/0.1/bulk', {
flags: Array, properties: Hash
}).and_call_original
subject.send(:store_ff_info, project: project, feature_flags: feature_flags)
end
end end
describe '#store_build_info' do describe '#store_build_info' do
......
...@@ -66,18 +66,6 @@ RSpec.describe FeatureFlags::CreateService do ...@@ -66,18 +66,6 @@ RSpec.describe FeatureFlags::CreateService do
subject subject
end end
context 'the feature flag is disabled' do
before do
stub_feature_flags(jira_sync_feature_flags: false)
end
it 'does not sync the feature flag to Jira' do
expect(::JiraConnect::SyncFeatureFlagsWorker).not_to receive(:perform_async)
subject
end
end
it 'creates audit event' do it 'creates audit event' do
expected_message = 'Created feature flag <strong>feature_flag</strong> '\ expected_message = 'Created feature flag <strong>feature_flag</strong> '\
'with description <strong>"description"</strong>. '\ 'with description <strong>"description"</strong>. '\
......
...@@ -26,18 +26,6 @@ RSpec.describe FeatureFlags::UpdateService do ...@@ -26,18 +26,6 @@ RSpec.describe FeatureFlags::UpdateService do
expect(subject[:status]).to eq(:success) expect(subject[:status]).to eq(:success)
end end
context 'the feature flag is disabled' do
before do
stub_feature_flags(jira_sync_feature_flags: false)
end
it 'does not sync the feature flag to Jira' do
expect(::JiraConnect::SyncFeatureFlagsWorker).not_to receive(:perform_async)
subject
end
end
it 'syncs the feature flag to Jira' do it 'syncs the feature flag to Jira' do
expect(::JiraConnect::SyncFeatureFlagsWorker).to receive(:perform_async).with(Integer, Integer) expect(::JiraConnect::SyncFeatureFlagsWorker).to receive(:perform_async).with(Integer, Integer)
......
...@@ -32,29 +32,5 @@ RSpec.describe ::JiraConnect::SyncFeatureFlagsWorker do ...@@ -32,29 +32,5 @@ RSpec.describe ::JiraConnect::SyncFeatureFlagsWorker do
subject subject
end end
end end
context 'when the feature flag is disabled' do
before do
stub_feature_flags(jira_sync_feature_flags: false)
end
it 'does not call the sync service' do
expect_next(::JiraConnect::SyncService).not_to receive(:execute)
subject
end
end
context 'when the feature flag is enabled for this project' do
before do
stub_feature_flags(jira_sync_feature_flags: feature_flag.project)
end
it 'calls the sync service' do
expect_next(::JiraConnect::SyncService).to receive(:execute)
subject
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment